kyverno: [Bug] webhooks are not removed when using Argo CD with Kyverno helm chart
Kyverno Version
1.10.3
Description
In https://github.com/kyverno/kyverno/pull/3148, a pre-delete hook was added to the Kyvenro helm chart to address https://github.com/kyverno/kyverno/issues/7576, where the cluster becomes deadlocked by the Kyverno “failing closed” when the Kyverno’s webhooks services are down (or have been deleted during uninstall).
However, this solution does not work when the helm chart is deployed by Argo CD, because Argo CD does not support helm.sh/hook: pre-delete hooks. This means that every user will deadlock their cluster when trying to uninstall Kyverno, if it was deployed as an Argo CD application.
The only sensible solution I can see is to copy what Istio does, and include the webhooks in the chart itself (with failurePolicy set to Ignore, rather than Fail), but still have the the controllers inject CA’s and change the failurePolicy back to Fail once they are up and running.
This will mean that helm itself will delete the ValidatingWebhookConfigurations and MutatingWebhookConfigurations when it uninstalls the app, removing the need to have a pre-delete job (and any possibility that the webhooks are left on uninstall to deadlock the cluster).
It also means that during upgrades, helm will always reset the failurePolicy to Ignore (good for safety), which is then only reverted once there is a Kyverno controller running.
See https://github.com/kyverno/kyverno/issues/8390#issuecomment-1719985272 for more information about a proper solution.
It is important to note that this issue is not solely present for users of Argo CD, because the pre-delete hook has a race condition with the controllers, which could result in them re-creating the webhooks after the job deletes them.
Currently, the pre-delete hook tries to address this with a 30s timer after scaling down the deployments, but this is not 100% safe:
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 3 years ago
- Reactions: 4
- Comments: 15 (15 by maintainers)
Those jobs are scheduled in the kyverno namespace which is excluded by default.
IIRC a cluster-wide resource (validatingwebhookconfiguration) can’t have a namespaced resource (deployment) as its owner. @thesuperzapper mentioned above to set the ClusterRole as the owner but I agree with @eddycharly that the webhooks should be removed when the Kyverno controllers are uninstalled.
This is interesting, I wonder what it does if there’s an empty webhook created with no endpoint registered?
@aslafy-z I am not sure PostDelete jobs will always work for Kyverno, because Kyverno could actually block the submission of new Jobs/Pods depending on the ClusterPolicies which existed at the time of uninstall.