allow Kyverno policies webhooks in kube-system / fix policies related to rke2 HelmCharts
This MR:
- fixes policies acting in the
kube-systemnamespace (in particularprevent-rke2-helmcharts-calico-metallbandblock-rke2-uninstall-jobs) - additionally, for the
block-rke2-uninstall-jobsan optimization is made to ensure that no webhook call will trigger for Jobs that don't meet the criteria
Before this MR, we're using Kyverno chart default configuration which excludes
the kube-system namespace from Kyverno admission control webhooks, making some of our
policies ineffective.
After this MR, we do not exclude the kube-system namespace systematically:
- Kyverno policies that do not set
spec.webhookConfiguration.matchConditionswill get default matchConditions that exclude thekube-systemnamespace (with the exception of Jobs, which is used by a policy acting in kube-system namespace) - Kyverno policies that do specificy
spec.webhookConfiguration.matchConditionsneed to excludekube-systemnamespace explicitly in theirmatchConditionsfield -- to make this light to implement, this MR provides a kustomize component that will add a matchConditions item to exclude kube-system namespace
This MR should make the block-rke2-uninstall-jobs and prevent-rke2-helmcharts-calico-metallb
policies work (the latter will already work for MetalLB with with !3381 (merged)).
Since this MR is making the block-rke2-uninstall-jobs policy actually work, it would actually prevent the deletion of the metallb HelmChart done in metallb-rke2-chart-cleanup unit. To resolve this point the unit script is modified in this MR (patching the RKE2 HelmChart with an annotation telling the controller to ignore it, and removing the finalizer, before deleting it).
This MR is desirable to have for !3218 (merged), to be 100% of reducing interference from RKE2 HelmChart controller, and hence desirable for 1.2.x.