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/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 rules:
15 - name: add-nodeselector
16 match:
17 resources:
18 kinds:
19 - Pod
20 # Adds the `nodeSelector` field to any Pod with two labels.
21 mutate:
22 patchStrategicMerge:
23 spec:
24 nodeSelector:
25 foo: bar
26 color: orange