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
/other/add-labels/add-labels.yaml
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/minversion: 1.6.0
9 policies.kyverno.io/severity: medium
10 policies.kyverno.io/subject: Label
11 policies.kyverno.io/description: >-
12 Labels are used as an important source of metadata describing objects in various ways
13 or triggering other functionality. Labels are also a very basic concept and should be
14 used throughout Kubernetes. This policy performs a simple mutation which adds a label
15 `foo=bar` to Pods, Services, ConfigMaps, and Secrets.
16spec:
17 rules:
18 - name: add-labels
19 match:
20 any:
21 - resources:
22 kinds:
23 - Pod
24 - Service
25 - ConfigMap
26 - Secret
27 mutate:
28 patchStrategicMerge:
29 metadata:
30 labels:
31 foo: bar