Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rverchere/f53f951bc3caa585f6e414dcf8434c5c to your computer and use it in GitHub Desktop.

Select an option

Save rverchere/f53f951bc3caa585f6e414dcf8434c5c to your computer and use it in GitHub Desktop.
Kyverno ClusterPolicy Rancher Secrets Webhookconfiguration
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: mutate-rancher-secrets-webhookconfiguration
annotations:
policies.kyverno.io/title: Filter Rancher secrets WebhookConfiguration
policies.kyverno.io/description: >-
Filter Rancher WebhookConfiguration to match secrets not in the `kube-system` namespace
spec:
mutateExistingOnPolicyUpdate: true
rules:
- name: mutate-rancher-secrets-mutatingwebhookconfiguration
match:
any:
- resources:
kinds:
- MutatingWebhookConfiguration
names:
- rancher.cattle.io
mutate:
targets:
- apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
name: rancher.cattle.io
patchStrategicMerge:
webhooks:
- name: rancher.cattle.io.secrets
namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: NotIn
values:
- kube-system
- name: mutate-rancher-secrets-validatingwebhookconfigurations
match:
any:
- resources:
kinds:
- ValidatingWebhookConfiguration
names:
- rancher.cattle.io
mutate:
targets:
- apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
name: rancher.cattle.io
patchStrategicMerge:
webhooks:
- name: rancher.cattle.io.secrets
namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: NotIn
values:
- kube-system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment