kyverno: [Bug] Webhooks are removed when Kyverno deployment scaled to zero
Kyverno Version
1.9.0
Kubernetes Version
1.26.x
Kubernetes Platform
Minikube
Kyverno Rule Type
Validate
Description
Hi all!
Since version 1.9.0 the validatingwebhookconfiguration kyverno-resource-validating-webhook-cfg gets deleted when the deployment is scaled down to 0.
If there is no webhook in place anymore, creation of resources is not blocked anymore as it was with prior versions (considering flag failurePolicy: Fail ). This potentially opens door for attackers.
I know this feature came into play to cleanup webhooks when uninstalling with helm. There it is fine. But I don’t see that is also has to be cleaned up when “just” scaling down.
What do you think?
Steps to reproduce
- scale down deployment to 0 with
kubectl scale deploy kyverno --replicas=0 -n kyverno - webhook is gone, check with
kubectl get validatingwebhookconfiguration kyverno-resource-validating-webhook-cfg -n kyverno
Expected behavior
Webhook should still be still in place. Creation of ressources affected should fail when failurePolicy: Fail, should be okay when failurePolicy: Ignore
Screenshots
No response
Kyverno logs
No response
Slack discussion
No response
Troubleshooting
- I have read and followed the documentation AND the troubleshooting guide.
- I have searched other issues in this repository and mine is not recorded.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 19 (8 by maintainers)
Thanks. This does seem like a problem so I’ll create a new issue.
We would like to fail the admission request for new pods / deployments if kyverno is down (for whatever reason, may it be due to malicious activities or accidental deletions).
Also, we noticed that when creating an invalid network policy (so that the webhook can’t be reached anymore), the webhook is deleted from the validatingwebhookconfiguration. I guess this is done by kyverno? It also leads to allowing all requests even though the failure policy is set to Fail.
On the other hand, scaling down kyverno to 0 and the webhooks around is going to make the cluster unhappy. We want to prevent outages as much as possible.
I see a couple of reasons for service going down but webhook should remain:
It is another important security gate to pass.
Why is it that you’d expect the webhook to remain if someone has permission to scale the Kyverno deployment to zero? If someone has permission to scale Kyverno they likely have many more permissions as well.
cc @eddycharly