Skip to content

Commit 9a49ace

Browse files
authored
Merge pull request #62484 from mburke5678/nodes-scheduler-fix-errors
NodesScheduler docs fixes during ROSA review
2 parents 6a46ed6 + 3e74024 commit 9a49ace

20 files changed

+314
-144
lines changed

modules/nodes-cluster-overcommit-configure-nodes.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ $ sysctl -a |grep commit
3232
.Example output
3333
[source,terminal]
3434
----
35-
vm.overcommit_memory = 1
35+
#...
36+
vm.overcommit_memory = 0
37+
#...
3638
----
3739

3840
[source,terminal]
@@ -43,7 +45,9 @@ $ sysctl -a |grep panic
4345
.Example output
4446
[source,terminal]
4547
----
48+
#...
4649
vm.panic_on_oom = 0
50+
#...
4751
----
4852

4953
[NOTE]

modules/nodes-scheduler-node-affinity-about.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ spec:
4444
containers:
4545
- name: with-node-affinity
4646
image: docker.io/ocpqe/hello-pod
47+
#...
4748
----
4849

4950
<1> The stanza to configure node affinity.
@@ -75,6 +76,7 @@ spec:
7576
containers:
7677
- name: with-node-affinity
7778
image: docker.io/ocpqe/hello-pod
79+
#...
7880
----
7981

8082
<1> The stanza to configure node affinity.

modules/nodes-scheduler-node-affinity-configuring-preferred.adoc

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,43 @@ The following steps demonstrate a simple configuration that creates a node and a
1919
$ oc label node node1 e2e-az-name=e2e-az3
2020
----
2121

22-
. In the `Pod` spec, use the `nodeAffinity` stanza to configure the `preferredDuringSchedulingIgnoredDuringExecution` parameter:
22+
. Create a pod with a specific label:
2323
+
24-
.. Specify a weight for the node, as a number 1-100. The node with highest weight is preferred.
24+
.. Create a YAML file with the following content:
2525
+
26-
.. 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:
26+
[NOTE]
27+
====
28+
You cannot add an affinity directly to a scheduled pod.
29+
====
2730
+
2831
[source,yaml]
2932
----
33+
apiVersion: v1
34+
kind: Pod
35+
metadata:
36+
name: s1
3037
spec:
31-
affinity:
38+
affinity: <1>
3239
nodeAffinity:
33-
preferredDuringSchedulingIgnoredDuringExecution:
34-
- weight: 1
40+
preferredDuringSchedulingIgnoredDuringExecution: <2>
41+
- weight: <3>
3542
preference:
3643
matchExpressions:
37-
- key: e2e-az-name
38-
operator: In
44+
- key: e2e-az-name <4>
3945
values:
4046
- e2e-az3
47+
operator: In <5>
48+
#...
4149
----
42-
+
43-
.. 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.
50+
<1> Adds a pod affinity.
51+
<2> Configures the `preferredDuringSchedulingIgnoredDuringExecution` parameter.
52+
<3> Specifies a weight for the node, as a number 1-100. The node with highest weight is preferred.
53+
<4> Specifies 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 `values` parameters as the label in the node.
54+
<5> Specifies an `operator`. The operator can be `In`, `NotIn`, `Exists`, or `DoesNotExist`. For example, use the operator `In` to require the label to be in the node.
4455

45-
. Create the pod.
56+
.. Create the pod.
4657
+
4758
[source,terminal]
4859
----
49-
$ oc create -f e2e-az3.yaml
60+
$ oc create -f <file-name>.yaml
5061
----

modules/nodes-scheduler-node-affinity-configuring-required.adoc

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,47 @@ metadata:
3131
name: <node_name>
3232
labels:
3333
e2e-az-name: e2e-az1
34+
#...
3435
----
3536
====
3637

37-
. In the `Pod` spec, use the `nodeAffinity` stanza to configure the `requiredDuringSchedulingIgnoredDuringExecution` parameter:
38+
. Create a pod with a specific label in the pod spec:
3839
+
39-
.. 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.
40+
.. Create a YAML file with the following content:
4041
+
41-
.. 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:
42+
[NOTE]
43+
====
44+
You cannot add an affinity directly to a scheduled pod.
45+
====
4246
+
4347
.Example output
4448
[source,yaml]
4549
----
50+
apiVersion: v1
51+
kind: Pod
52+
metadata:
53+
name: s1
4654
spec:
47-
affinity:
55+
affinity: <1>
4856
nodeAffinity:
49-
requiredDuringSchedulingIgnoredDuringExecution:
57+
requiredDuringSchedulingIgnoredDuringExecution: <2>
5058
nodeSelectorTerms:
5159
- matchExpressions:
52-
- key: e2e-az-name
53-
operator: In
60+
- key: e2e-az-name <3>
5461
values:
5562
- e2e-az1
5663
- e2e-az2
64+
operator: In <4>
65+
#...
5766
----
67+
<1> Adds a pod affinity.
68+
<2> Configures the `requiredDuringSchedulingIgnoredDuringExecution` parameter.
69+
<3> Specifies 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 `values` parameters as the label in the node.
70+
<4> Specifies an `operator`. The operator can be `In`, `NotIn`, `Exists`, or `DoesNotExist`. For example, use the operator `In` to require the label to be in the node.
5871

59-
. Create the pod:
72+
.. Create the pod:
6073
+
6174
[source,terminal]
6275
----
63-
$ oc create -f e2e-az2.yaml
76+
$ oc create -f <file-name>.yaml
6477
----

modules/nodes-scheduler-node-affinity-example.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// * nodes/nodes-scheduler-node-affinity.adoc
44

5-
[id="nodes-scheduler-node-affinity-examples_{context}"]
5+
[id="nodes-scheduler-node-affinity-example_{context}"]
66
= Sample node affinity rules
77

88
The following examples demonstrate node affinity.
@@ -31,6 +31,7 @@ metadata:
3131
name: <node_name>
3232
labels:
3333
zone: us
34+
#...
3435
----
3536
====
3637

@@ -61,6 +62,7 @@ spec:
6162
operator: In
6263
values:
6364
- us
65+
#...
6466
----
6567

6668
* The pod-s1 pod can be scheduled on Node1:
@@ -101,6 +103,7 @@ metadata:
101103
name: <node_name>
102104
labels:
103105
zone: emea
106+
#...
104107
----
105108
====
106109

@@ -131,6 +134,7 @@ spec:
131134
operator: In
132135
values:
133136
- us
137+
#...
134138
----
135139

136140
* The pod-s1 pod cannot be scheduled on Node1:

modules/nodes-scheduler-node-selectors-about.adoc

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ metadata:
6262
kubernetes.io/arch: amd64
6363
region: east <1>
6464
type: user-node
65+
#...
6566
----
6667
<1> Labels to match the pod node selector.
6768
endif::openshift-origin[]
@@ -72,7 +73,7 @@ ifdef::openshift-origin[]
7273
kind: Node
7374
apiVersion: v1
7475
metadata:
75-
name: ip-10-0-131-14.ec2.internal
76+
name: s1
7677
selfLink: /api/v1/nodes/ip-10-0-131-14.ec2.internal
7778
uid: 7bc2580a-8b8e-11e9-8e01-021ab4174c74
7879
resourceVersion: '478704'
@@ -89,6 +90,7 @@ metadata:
8990
kubernetes.io/arch: amd64
9091
region: east <1>
9192
type: user-node
93+
#...
9294
----
9395
<1> Labels to match the pod node selector.
9496
endif::openshift-origin[]
@@ -100,13 +102,14 @@ A pod has the `type: user-node,region: east` node selector:
100102
----
101103
apiVersion: v1
102104
kind: Pod
103-
104-
....
105-
105+
metadata:
106+
name: s1
107+
#...
106108
spec:
107109
nodeSelector: <1>
108110
region: east
109111
type: user-node
112+
#...
110113
----
111114
<1> Node selectors to match the node label. The node must have a label for each node selector.
112115
+
@@ -126,11 +129,10 @@ apiVersion: config.openshift.io/v1
126129
kind: Scheduler
127130
metadata:
128131
name: cluster
129-
...
130-
132+
#...
131133
spec:
132134
defaultNodeSelector: type=user-node,region=east
133-
...
135+
#...
134136
----
135137
+
136138
A node in that cluster has the `type=user-node,region=east` labels:
@@ -142,24 +144,25 @@ apiVersion: v1
142144
kind: Node
143145
metadata:
144146
name: ci-ln-qg1il3k-f76d1-hlmhl-worker-b-df2s4
145-
...
147+
#...
146148
labels:
147149
region: east
148150
type: user-node
149-
...
151+
#...
150152
----
151153
+
152154
.Example `Pod` object with a node selector
153155
[source,terminal]
154156
----
155157
apiVersion: v1
156158
kind: Pod
157-
...
158-
159+
metadata:
160+
name: s1
161+
#...
159162
spec:
160163
nodeSelector:
161164
region: east
162-
...
165+
#...
163166
----
164167
+
165168
When you create the pod using the example pod spec in the example cluster, the pod is created with the cluster-wide node selector and is scheduled on the labeled node:
@@ -192,7 +195,7 @@ metadata:
192195
name: east-region
193196
annotations:
194197
openshift.io/node-selector: "region=east"
195-
...
198+
#...
196199
----
197200
+
198201
The following node has the `type=user-node,region=east` labels:
@@ -204,11 +207,11 @@ apiVersion: v1
204207
kind: Node
205208
metadata:
206209
name: ci-ln-qg1il3k-f76d1-hlmhl-worker-b-df2s4
207-
...
210+
#...
208211
labels:
209212
region: east
210213
type: user-node
211-
...
214+
#...
212215
----
213216
+
214217
When you create the pod using the example pod spec in this example project, the pod is created with the project node selectors and is scheduled on the labeled node:
@@ -220,12 +223,12 @@ apiVersion: v1
220223
kind: Pod
221224
metadata:
222225
namespace: east-region
223-
...
226+
#...
224227
spec:
225228
nodeSelector:
226229
region: east
227230
type: user-node
228-
...
231+
#...
229232
----
230233
+
231234
[source,terminal]
@@ -242,11 +245,11 @@ A pod in the project is not created or scheduled if the pod contains different n
242245
----
243246
apiVersion: v1
244247
kind: Pod
245-
...
246-
248+
metadata:
249+
name: west-region
250+
#...
247251
spec:
248252
nodeSelector:
249253
region: west
250-
251-
....
254+
#...
252255
----

0 commit comments

Comments
 (0)