Skip to content

Instantly share code, notes, and snippets.

@J4NS-R
Last active November 23, 2025 11:59
Show Gist options
  • Select an option

  • Save J4NS-R/4d5cdb1f57edfe8c74e674dfa7fef695 to your computer and use it in GitHub Desktop.

Select an option

Save J4NS-R/4d5cdb1f57edfe8c74e674dfa7fef695 to your computer and use it in GitHub Desktop.
Bitnami to bitnamilegacy kyverno policy
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: replace-bitnami-with-bitnamilegacy
annotations:
pod-policies.kyverno.io/autogen-controllers: none # do not modify pod controllers (deployments, sts, cronjob)
spec:
background: false # only on pod creation
rules:
- name: replace-bitnami-image
match:
any:
- resources:
kinds:
- Pod
mutate:
foreach:
- list: "request.object.spec.containers[]"
patchStrategicMerge:
spec:
containers:
- name: "{{ element.name }}"
image: "{{ regex_replace_all('bitnami/', element.image, 'bitnamilegacy/') }}"
- name: replace-bitnami-initcontainers
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.object.spec.initContainers[] || `[]` | length(@) }}"
operator: GreaterThanOrEquals
value: 1
mutate:
foreach:
- list: "request.object.spec.initContainers[]"
patchStrategicMerge:
spec:
initContainers:
- name: "{{ element.name }}"
image: "{{ regex_replace_all('bitnami/', element.image, 'bitnamilegacy/') }}"
webhookConfiguration:
failurePolicy: Ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment