All Policies
Verify Image with Multiple Keys
There may be multiple keys used to sign images based on the parties involved in the creation process. This image verification policy looks like a global key in a ConfigMap and also an image-specific key in the same ConfigMap.
Policy Definition
/other/verify_image_with_multi_keys.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: verify-image-with-multi-keys
5 annotations:
6 policies.kyverno.io/title: Verify Image with Multiple Keys
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Pod
10 policies.kyverno.io/minversion: 1.5.0
11 policies.kyverno.io/description: >-
12 There may be multiple keys used to sign images based on
13 the parties involved in the creation process. This image
14 verification policy looks like a global key in a ConfigMap
15 and also an image-specific key in the same ConfigMap.
16spec:
17 validationFailureAction: enforce
18 background: false
19 rules:
20 - name: check-image-with-two-keys
21 match:
22 any:
23 - resources:
24 kinds:
25 - Pod
26 context:
27 - name: keys
28 configMap:
29 name: keys
30 namespace: default
31 verifyImages:
32 # check global key
33 - image: "*"
34 key: "{{ keys.data.org }}"
35 # check image specific key - lookup via image name
36 - image: "ghcr.io/kyverno/*"
37 key: "{{ keys.data.{{ images.name }} }}"