kyverno 如何处理生成资源的清理
假设我在 kyverno 集群策略中有一条规则来生成 configmap。现在,在将来的某个时间点,我会从集群策略中删除该规则(集群策略仍然存在)。 kyverno 能够对 configmap 进行垃圾收集吗?
具有两个生成规则(r1 和 r2)的集群策略:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: cp1
spec:
rules:
- name: r1
match:
resources:
kinds:
- Namespace
selector:
matchLabels:
test: "true"
generate:
synchronize: true
kind: ConfigMap
name: cm1
namespace: "{{request.object.metadata.name}}"
data:
kind: ConfigMap
data:
# Enter all your target logging info below
test.yml: |-
cm1
- name: r2
match:
resources:
kinds:
- Namespace
selector:
matchLabels:
test: "true"
generate:
synchronize: true
kind: ConfigMap
name: cm2
namespace: "{{request.object.metadata.name}}"
data:
kind: ConfigMap
data:
# Enter all your target logging info below
test.yml: |-
cm2
一旦应用,如果您删除生成规则之一并再次应用策略,它不会删除配置映射。
Let's say I have a rule in kyverno cluster policy to generate configmap. Now at some point of time in future I remove that rule from cluster policy(cluster policy still exists). Is kyverno capable of garbage collecting the configmap?
Cluster Policy with two generate rules(r1 and r2):
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: cp1
spec:
rules:
- name: r1
match:
resources:
kinds:
- Namespace
selector:
matchLabels:
test: "true"
generate:
synchronize: true
kind: ConfigMap
name: cm1
namespace: "{{request.object.metadata.name}}"
data:
kind: ConfigMap
data:
# Enter all your target logging info below
test.yml: |-
cm1
- name: r2
match:
resources:
kinds:
- Namespace
selector:
matchLabels:
test: "true"
generate:
synchronize: true
kind: ConfigMap
name: cm2
namespace: "{{request.object.metadata.name}}"
data:
kind: ConfigMap
data:
# Enter all your target logging info below
test.yml: |-
cm2
Once applied if you remove one of the generate rules and apply policy again it does not remove config map.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有一个
generate
规则,该规则使用带有synchronize: false
的data
声明(而不是clone
声明),删除规则将导致下游资源的删除。我们目前有一个错误影响了这一点,但它应该以这种方式工作。If you have a
generate
rule which uses adata
declaration (not aclone
one) withsynchronize: false
, deleting of the rule will cause deletion of the downstream resource(s). We currently have a bug impacting this, but it's supposed to work this way.