allow Kyverno policies webhooks in kube-system / fix policies related to rke2 HelmCharts

This MR:

  • fixes policies acting in the kube-system namespace (in particular prevent-rke2-helmcharts-calico-metallb and block-rke2-uninstall-jobs)
  • additionally, for the block-rke2-uninstall-jobs an 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.matchConditions will get default matchConditions that exclude the kube-system namespace (with the exception of Jobs, which is used by a policy acting in kube-system namespace)
  • Kyverno policies that do specificy spec.webhookConfiguration.matchConditions need to exclude kube-system namespace explicitly in their matchConditions field -- 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.

Edited by Thomas Morin

Merge request reports

Loading