1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nodes-scheduler-node-affinity-configuring-required.adoc
2019-05-13 13:57:48 +10:00

46 lines
1.3 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes-scheduler-node-affinity.adoc
[id="nodes-scheduler-node-affinity-configuring-required_{context}"]
= Configuring a required node affinity rule
Required rules *must* be met before a pod can be scheduled on a node.
.Procedure
The following steps demonstrate a simple configuration that creates a node and a pod that the scheduler is required to place on the node.
. Add a label to a node using the `oc label node` command:
+
----
$ oc label node node1 e2e-az-name=e2e-az1
----
. In the pod specification, use the `nodeAffinity` stanza to configure the `requiredDuringSchedulingIgnoredDuringExecution` parameter:
+
.. Specify the key and values that must be met. If you want the new pod to be scheduled on the node you edited, use the same `key` and `value` parameters as the label in the node.
+
.. Specify an `operator`. The operator can be `In`, `NotIn`, `Exists`, `DoesNotExist`, `Lt`, or `Gt`. For example, use the operator `In` to require the label to be in the node:
+
----
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: e2e-az-name
operator: In
values:
- e2e-az1
- e2e-az2
----
. Create the pod:
+
----
$ oc create -f e2e-az2.yaml
----