Skip to content

Commit

Permalink
add an command example for examples/karmadactlinterpret/README.md
Browse files Browse the repository at this point in the history
update the example resourceinterpretercustomization with kube lib for building dependencyInterpretation

Signed-off-by: yike21 <yike21@qq.com>
  • Loading branch information
yike21 committed Apr 17, 2023
1 parent 4552a19 commit c138113
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
8 changes: 7 additions & 1 deletion examples/karmadactlinterpret/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ karmadactl interpret -f resourceinterpretercustomization.yaml --check
*Execute the InterpretReplica rule*

```shell
karmadactl interpret -f resourceinterpretercustomization.yaml --observed-file observed-deploy-nginx.yaml --operation=InterpretReplica
karmadactl interpret -f resourceinterpretercustomization.yaml --observed-file observed-deploy-nginx.yaml --operation InterpretReplica
```

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

*Execute the ReviseReplica rule*

```shell
karmadactl interpret -f resourceinterpretercustomization.yaml --desired-replica 3 --observed-file observed-deploy-nginx.yaml --operation ReviseReplica
```

*Execute the InterpretStatus rule*

```shell
Expand Down
17 changes: 2 additions & 15 deletions examples/karmadactlinterpret/resourceinterpretercustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,8 @@ spec:
end
dependencyInterpretation:
luaScript: >
local kube = require("kube")
function GetDependencies(desiredObj)
dependentSas = {}
refs = {}
if desiredObj.spec.template.spec.serviceAccountName ~= '' and desiredObj.spec.template.spec.serviceAccountName ~= 'default' then
dependentSas[desiredObj.spec.template.spec.serviceAccountName] = true
end
local idx = 1
for key, value in pairs(dependentSas) do
dependObj = {}
dependObj.apiVersion = 'v1'
dependObj.kind = 'ServiceAccount'
dependObj.name = key
dependObj.namespace = desiredObj.metadata.namespace
refs[idx] = dependObj
idx = idx + 1
end
refs = kube.getPodDependencies(desiredObj.spec.template, desiredObj.metadata.namespace)
return refs
end

0 comments on commit c138113

Please sign in to comment.