All Policies
Add nodeSelector
The nodeSelector field uses labels to select the node on which a Pod can be scheduled. This can be useful when Pods have specific needs that only certain nodes in a cluster can provide. This policy adds the nodeSelector field to a Pod spec and configures it with labels `foo` and `color`.
Policy Definition
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: add-nodeselector
5 annotations:
6 policies.kyverno.io/title: Add nodeSelector
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/subject: Pod
9 policies.kyverno.io/description: >-
10 The nodeSelector field uses labels to select the node on which a Pod can be scheduled.
11 This can be useful when Pods have specific needs that only certain nodes in a cluster can provide.
12 This policy adds the nodeSelector field to a Pod spec and configures it with labels `foo` and `color`.
13spec:
14 background: false
15 rules:
16 - name: add-nodeselector
17 match:
18 resources:
19 kinds:
20 - Pod
21 # Adds the `nodeSelector` field to any Pod with two labels.
22 mutate:
23 patchStrategicMerge:
24 spec:
25 nodeSelector:
26 foo: bar
27 color: orange