Skip to content

Commit 6687479

Browse files
authored
Merge pull request #3412 from yike21/update-document-for-karmadactlinterpret
add an example for examples/karmadactlinterpret/README.md
2 parents 4552a19 + c138113 commit 6687479

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

examples/karmadactlinterpret/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ karmadactl interpret -f resourceinterpretercustomization.yaml --check
1111
*Execute the InterpretReplica rule*
1212

1313
```shell
14-
karmadactl interpret -f resourceinterpretercustomization.yaml --observed-file observed-deploy-nginx.yaml --operation=InterpretReplica
14+
karmadactl interpret -f resourceinterpretercustomization.yaml --observed-file observed-deploy-nginx.yaml --operation InterpretReplica
1515
```
1616

1717
*Execute the Retain rule*
@@ -20,6 +20,12 @@ karmadactl interpret -f resourceinterpretercustomization.yaml --observed-file ob
2020
karmadactl interpret -f resourceinterpretercustomization.yaml --desired-file desired-deploy-nginx.yaml --observed-file observed-deploy-nginx.yaml --operation Retain
2121
```
2222

23+
*Execute the ReviseReplica rule*
24+
25+
```shell
26+
karmadactl interpret -f resourceinterpretercustomization.yaml --desired-replica 3 --observed-file observed-deploy-nginx.yaml --operation ReviseReplica
27+
```
28+
2329
*Execute the InterpretStatus rule*
2430

2531
```shell

examples/karmadactlinterpret/resourceinterpretercustomization.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,8 @@ spec:
5757
end
5858
dependencyInterpretation:
5959
luaScript: >
60+
local kube = require("kube")
6061
function GetDependencies(desiredObj)
61-
dependentSas = {}
62-
refs = {}
63-
if desiredObj.spec.template.spec.serviceAccountName ~= '' and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
64-
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
65-
end
66-
local idx = 1
67-
for key, value in pairs(dependentSas) do
68-
dependObj = {}
69-
dependObj.apiVersion = 'v1'
70-
dependObj.kind = 'ServiceAccount'
71-
dependObj.name = key
72-
dependObj.namespace = desiredObj.metadata.namespace
73-
refs[idx] = dependObj
74-
idx = idx + 1
75-
end
62+
refs = kube.getPodDependencies(desiredObj.spec.template, desiredObj.metadata.namespace)
7663
return refs
7764
end

0 commit comments

Comments
 (0)