Open anushkamittal2001 opened 3 months ago
You should set the operations to CREATE
and UPDATE
as follows:
- resources:
kinds:
- RoleBinding
- ClusterRoleBinding
operations:
- CREATE
- UPDATE
This is because there are recent changes to apply cel
policies to a deleted resource so by default, all operations are set.
Let me know if this solves the issue.
Let me check this out. Thanks @MariamFahmy98
@MariamFahmy98 Could you help me understand why the good pod gets created but doesnt get deleted.
If it is a good pod both should be allowed right
@MariamFahmy98 Could you help me understand why the good pod gets created but doesnt get deleted.
If it is a good pod both should be allowed right
By not setting operations, the policy defaults to all operations. Therefore, when deleting the pod, the policy is applied and the CEL expression fails with the error no such key: roleRef'
. This is because the resource is deleted and there is no roleRef
field so it is important to set operations to CREATE
and UPDATE
to avoid applying policies on deleted resource.
Thanks @MariamFahmy98! Is there documentation for this that you can point me to?
Hi, @anushkamittal2001. I'm helping the kyverno team manage their backlog and am marking this issue as stale.
Your issue highlights a bug in Kyverno version 1.12.5, where a CEL policy in enforce mode is preventing the deletion of a valid ClusterRoleBinding resource. You mentioned seeking further clarification and documentation on this behavior, and MariamFahmy98 suggested adjusting the policy to specify only CREATE
and UPDATE
operations to avoid applying the policy during deletion, which resulted in an error due to the absence of the roleRef
field.
Could you please let us know if this issue is still relevant to the latest version of the kyverno repository? If it is, feel free to comment here to keep the discussion going. Otherwise, you can close the issue yourself, or it will be automatically closed in 7 days. Thank you!
Kyverno Version
1.12.5
Kubernetes Version
1.27.x
Kubernetes Platform
KinD
Kyverno Rule Type
Validate
Description
After applying cel policy in enforce mode, a good resource gets accepted, a bad resource gets blocked. But when I try to delete the good resource. it get blocked.
Steps to reproduce
Result
Expected behavior
I should have seen the good resource get deleted.
Screenshots
No response
Kyverno logs
No response
Slack discussion
No response
Troubleshooting