All Policies
Check Data Protection By Label
Check the 'dataprotection' label that production Deployments and StatefulSet have a named K10 Policy. Use in combination with 'generate' ClusterPolicy to 'generate' a specific K10 Policy by name.
Policy Definition
/kasten/k10-data-protection-by-label/k10-check-data-protection-by-label.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: k10-data-protection-by-label
5 annotations:
6 policies.kyverno.io/title: Check Data Protection By Label
7 policies.kyverno.io/category: Kasten K10 by Veeam
8 kyverno.io/kyverno-version: 1.6.2
9 policies.kyverno.io/minversion: 1.6.2
10 kyverno.io/kubernetes-version: "1.21-1.22"
11 policies.kyverno.io/subject: Deployment, StatefulSet
12 policies.kyverno.io/description: >-
13 Check the 'dataprotection' label that production Deployments and StatefulSet have a named K10 Policy.
14 Use in combination with 'generate' ClusterPolicy to 'generate' a specific K10 Policy by name.
15spec:
16 validationFailureAction: audit
17 rules:
18 - name: k10-data-protection-by-label
19 match:
20 any:
21 - resources:
22 kinds:
23 - Deployment
24 - StatefulSet
25 selector:
26 matchLabels:
27 purpose: production
28 validate:
29 message: "Deployments and StatefulSets that specify 'dataprotection' label must have a valid k10-?* name (use labels: dataprotection: k10-<policyname>)"
30 pattern:
31 metadata:
32 labels:
33 dataprotection: "k10-*"