Merge pull request #3412 from yike21/update-document-for-karmadactlinterpret

add an example for examples/karmadactlinterpret/README.md
This commit is contained in:
karmada-bot 2023-04-17 15:43:05 +08:00 committed by GitHub
commit 6687479543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 16 deletions

View File

@ -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

View File

@ -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