All Policies

Add imagePullSecrets

Images coming from certain registries require authentication in order to pull them, and the kubelet uses this information in the form of an imagePullSecret to pull those images on behalf of your Pod. This policy searches for images coming from a registry called `corp.reg.com` and, if found, will mutate the Pod to add an imagePullSecret called `my-secret`.

Policy Definition

/other/add-imagepullsecrets.yaml

 1apiVersion: kyverno.io/v1
 2kind: ClusterPolicy
 3metadata:
 4  name: add-imagepullsecrets
 5  annotations:
 6    policies.kyverno.io/title: Add imagePullSecrets
 7    policies.kyverno.io/category: Sample
 8    policies.kyverno.io/subject: Pod
 9    policies.kyverno.io/description: >-
10      Images coming from certain registries require authentication in order to pull them,
11      and the kubelet uses this information in the form of an imagePullSecret to pull 
12      those images on behalf of your Pod. This policy searches for images coming from a
13      registry called `corp.reg.com` and, if found, will mutate the Pod to add an
14      imagePullSecret called `my-secret`.      
15spec:
16  background: false
17  rules:
18  - name: add-imagepullsecret
19    match:
20      resources:
21        kinds:
22        - Pod
23    mutate:
24      patchStrategicMerge:
25        spec:
26          containers:
27          - (image): "corp.reg.com/*"
28          imagePullSecrets:
29          - name: my-secret