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
/other/add-nodeSelector/add-nodeSelector.yaml
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/minversion: 1.6.0
10 policies.kyverno.io/description: >-
11 The nodeSelector field uses labels to select the node on which a Pod can be scheduled.
12 This can be useful when Pods have specific needs that only certain nodes in a cluster can provide.
13 This policy adds the nodeSelector field to a Pod spec and configures it with labels `foo` and `color`.
14spec:
15 rules:
16 - name: add-nodeselector
17 match:
18 any:
19 - resources:
20 kinds:
21 - Pod
22 # Adds the `nodeSelector` field to any Pod with two labels.
23 mutate:
24 patchStrategicMerge:
25 spec:
26 nodeSelector:
27 foo: bar
28 color: orange