All Policies
Add Labels
Labels are used as an important source of metadata describing objects in various ways or triggering other functionality. Labels are also a very basic concept and should be used throughout Kubernetes. This policy performs a simple mutation which adds a label `foo=bar` to Pods, Services, ConfigMaps, and Secrets.
Policy Definition
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: add-labels
5 annotations:
6 policies.kyverno.io/title: Add Labels
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Label
10 policies.kyverno.io/description: >-
11 Labels are used as an important source of metadata describing objects in various ways
12 or triggering other functionality. Labels are also a very basic concept and should be
13 used throughout Kubernetes. This policy performs a simple mutation which adds a label
14 `foo=bar` to Pods, Services, ConfigMaps, and Secrets.
15spec:
16 rules:
17 - name: add-labels
18 match:
19 resources:
20 kinds:
21 - Pod
22 - Service
23 - ConfigMap
24 - Secret
25 mutate:
26 patchStrategicMerge:
27 metadata:
28 labels:
29 foo: bar