kyverno: [Bug] Incorrect NetworkPolicy causes Kyverno to remove its own webhook config
Following steps below, a NetworkPolicy which results in comms between Kyverno and the API server causes Kyverno to remove its own webhook rule from resource validating webhooks which results in resources bypassing validations.
Kyverno 1.10.1
To reproduce, please try this:
- Deploy kyverno with the helm chart v3.0.2 and this config (so calls from api-server are blocked)
admissionController: networkPolicy: enabled: true ingressFrom: - namespaceSelector: matchLabels: kubernetes.io/metadata.name: monitoring podSelector: matchLabels: app: prometheus - Restart admission-controller (not sure if required)
- Create some admission request (pod creation, this one should fail)
- Wait max 10min (sorry, couldn’t nail it down further yet).
- The webhook should be removed from the validatingwebhookconfiguration by now and the subsequent admission requests are passing
_Originally posted by @wiegandf in https://github.com/kyverno/kyverno/issues/6554#issuecomment-1642024960_
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Hi @realshuting, sorry for the long time without reply. I have overlooked your question and we also didn’t face this issue anymore.
Until recently, when we had some network issues and the webhook was deleted from the validatingwebhookconfiguration.
I was able to reproduce with the steps outlined in https://github.com/kyverno/kyverno/issues/7852#issue-1811889710.
I noticed that you’re deploying a new Networkpolicy that denies Egress traffic - so kyverno is also not able to update the validatingwebhookconfiguration. Could you try to install kyverno with the helm chart and the snippet from the steps above?
After restarting, all validatingwebhookconfigurations are correct:
A new resource should now be denied to be created because of a timeout:
So now, it’s important to wait some time - I guess kyverno is reconciling after some time? Anyway, after let’s say maximum 5-10mins, it should look like:
Please note that
kyverno-resource-validating-webhook-cfgis now missing the webhook.