add an command example for examples/karmadactlinterpret/README.md
update the example resourceinterpretercustomization with kube lib for building dependencyInterpretation Signed-off-by: yike21 <yike21@qq.com>
This commit is contained in:
parent
4552a19ee9
commit
c138113f6f
|
@ -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*
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue