Skip to content

Commit a17183d

Browse files
authored
Merge pull request #32553 from adellape/project_placement
2 parents 1141d2f + e23b12a commit a17183d

9 files changed

+90
-10
lines changed

modules/nodes-scheduler-taints-tolerations-adding-machineset.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Module included in the following assemblies:
22
//
3-
// * nodes/nodes-scheduler-taints-tolerations.adoc
3+
// * nodes/scheduling/nodes-scheduler-taints-tolerations.adoc
44
// * post_installation_configuration/node-tasks.adoc
55

66
[id="nodes-scheduler-taints-tolerations-adding-machineset_{context}"]

modules/nodes-scheduler-taints-tolerations-adding.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Module included in the following assemblies:
22
//
3-
// * nodes/nodes-scheduler-taints-tolerations.adoc
3+
// * nodes/scheduling/nodes-scheduler-taints-tolerations.adoc
44
// * post_installation_configuration/node-tasks.adoc
55

66
[id="nodes-scheduler-taints-tolerations-adding_{context}"]

modules/nodes-scheduler-taints-tolerations-binding.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Module included in the following assemblies:
22
//
3-
// * nodes/nodes-scheduler-taints-tolerations.adoc
3+
// * nodes/scheduling/nodes-scheduler-taints-tolerations.adoc
44
// * post_installation_configuration/node-tasks.adoc
55

66
[id="nodes-scheduler-taints-tolerations-bindings_{context}"]
@@ -24,5 +24,3 @@ $ oc adm taint nodes node1 dedicated=groupName:NoSchedule
2424
----
2525

2626
. Add a toleration to the pods by writing a custom admission controller.
27-
28-
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/scheduling/nodes-scheduler-taints-tolerations.adoc
4+
// * post_installation_configuration/node-tasks.adoc
5+
6+
[id="nodes-scheduler-taints-tolerations-projects_{context}"]
7+
= Creating a project with a node selector and toleration
8+
9+
You can create a project that uses a node selector and toleration, which are set as annotations, to control the placement of pods onto specific nodes. Any subsequent resources created in the project are then scheduled on nodes that have a taint matching the toleration.
10+
11+
.Prerequisites
12+
13+
* A label for node selection has been added to one or more nodes by using a machine set or editing the node directly.
14+
* A taint has been added to one or more nodes by using a machine set or editing the node directly.
15+
16+
.Procedure
17+
18+
. Create a `Project` resource definition, specifying a node selector and toleration in the `metadata.annotations` section:
19+
+
20+
.Example `project.yaml` file
21+
[source,yaml]
22+
----
23+
kind: Project
24+
apiVersion: project.openshift.io/v1
25+
metadata:
26+
name: <project_name> <1>
27+
annotations:
28+
openshift.io/node-selector: '<label>' <2>
29+
scheduler.alpha.kubernetes.io/defaultTolerations: >-
30+
[{"operator": "Exists", "effect": "NoSchedule", "key":
31+
"<key_name>"} <3>
32+
]
33+
----
34+
<1> The project name.
35+
<2> The default node selector label.
36+
<3> The toleration parameters, as described in the *Taint and toleration components* table. This example uses the `NoSchedule` effect, which allows existing pods on the node to remain, and the `Exists` operator, which does not take a value.
37+
38+
. Use the `oc apply` command to create the project:
39+
+
40+
[source,terminal]
41+
----
42+
$ oc apply -f project.yaml
43+
----
44+
45+
Any subsequent resources created in the `<project_name>` namespace should now be scheduled on the specified nodes.

modules/nodes-scheduler-taints-tolerations-removing.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Module included in the following assemblies:
22
//
3-
// * nodes/nodes-scheduler-taints-tolerations.adoc
3+
// * nodes/scheduling/nodes-scheduler-taints-tolerations.adoc
44
// * post_installation_configuration/node-tasks.adoc
55

66
[id="nodes-scheduler-taints-tolerations-removing_{context}"]

modules/olm-pod-placement.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/admin/olm-adding-operators-to-cluster.adoc
4+
5+
[id="olm-pod-placement_{context}"]
6+
= Pod placement of Operator workloads
7+
8+
By default, Operator Lifecycle Manager (OLM) places pods on arbitrary worker nodes when installing an Operator or deploying Operand workloads. As an administrator, you can use projects with a combination of node selectors, taints, and tolerations to control the placement of Operators and Operands to specific nodes.
9+
10+
Controlling pod placement of Operator and Operand workloads has the following prerequisites:
11+
12+
. Determine a node or set of nodes to target for the pods per your requirements. If available, note an existing label, such as `node-role.kubernetes.io/app`, that identifies the node or nodes. Otherwise, add a label, such as `myoperator`, by using a machine set or editing the node directly. You will use this label in a later step as the node selector on your project.
13+
. If you want to ensure that only pods with a certain label are allowed to run on the nodes, while steering unrelated workloads to other nodes, add a taint to the node or nodes by using a machine set or editing the node directly. Use an effect that ensures that new pods that do not match the taint cannot be scheduled on the nodes. For example, a `myoperator:NoSchedule` taint ensures that new pods that do not match the taint are not scheduled onto that node, but existing pods on the node are allowed to remain.
14+
. Create a project that is configured with a default node selector and, if you added a taint, a matching toleration.
15+
16+
At this point, the project you created can be used to steer pods towards the specified nodes in the following scenarios:
17+
18+
For Operator pods::
19+
Administrators can create a `Subscription` object in the project. As a result, the Operator pods are placed on the specified nodes.
20+
21+
For Operand pods::
22+
Using an installed Operator, users can create an application in the project, which places the custom resource (CR) owned by the Operator in the project. As a result, the Operand pods are placed on the specified nodes, unless the Operator is deploying cluster-wide objects or resources in other namespaces, in which case this customized pod placement does not apply.

nodes/scheduling/nodes-scheduler-node-selectors.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ toc::[]
99

1010
A _node selector_ specifies a map of key/value pairs that are defined using custom labels on nodes and selectors specified in pods.
1111

12-
For the pod to be eligible to run on a node, the pod must have the same key/value node selector as the label on the node.
12+
For the pod to be eligible to run on a node, the pod must have the same key/value node selector as the label on the node.
1313

1414
// The following include statements pull in the module files that comprise
1515
// the assembly. Include any combination of concept, procedure, or reference
@@ -24,6 +24,8 @@ include::modules/nodes-scheduler-node-selectors-pod.adoc[leveloffset=+1]
2424
include::modules/nodes-scheduler-node-selectors-cluster.adoc[leveloffset=+1]
2525

2626
include::modules/nodes-scheduler-node-selectors-project.adoc[leveloffset=+1]
27+
.Additional resources
2728

28-
// include::modules/nodes-scheduler-node-selectors-configuring.adoc[leveloffset=+1]
29+
* xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-projects_nodes-scheduler-taints-tolerations[Creating a project with a node selector and toleration]
2930
31+
// include::modules/nodes-scheduler-node-selectors-configuring.adoc[leveloffset=+1]

nodes/scheduling/nodes-scheduler-taints-tolerations.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ include::modules/nodes-scheduler-taints-tolerations-adding-machineset.adoc[level
2222

2323
include::modules/nodes-scheduler-taints-tolerations-binding.adoc[leveloffset=+2]
2424

25+
include::modules/nodes-scheduler-taints-tolerations-projects.adoc[leveloffset=+2]
26+
.Additional resources
27+
28+
* Adding taints and tolerations xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-adding_nodes-scheduler-taints-tolerations[manually to nodes] or xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-adding-machineset_nodes-scheduler-taints-tolerations[with machine sets]
29+
* xref:../../nodes/scheduling/nodes-scheduler-node-selectors.adoc#nodes-scheduler-node-selectors-project_nodes-scheduler-node-selectors[Creating project-wide node selectors]
30+
* xref:../../operators/admin/olm-adding-operators-to-cluster.adoc#olm-pod-placement_olm-adding-operators-to-a-cluster[Pod placement of Operator workloads]
31+
2532
include::modules/nodes-scheduler-taints-tolerations-special.adoc[leveloffset=+2]
2633

2734
include::modules/nodes-scheduler-taints-tolerations-removing.adoc[leveloffset=+1]
2835

2936
//Removed per upstream docs modules/nodes-scheduler-taints-tolerations-evictions.adoc[leveloffset=+1]
30-
31-

operators/admin/olm-adding-operators-to-cluster.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@ include::modules/olm-installing-specific-version-cli.adoc[leveloffset=+1]
3333
.Additional resources
3434

3535
* xref:../../operators/admin/olm-upgrading-operators.adoc#olm-approving-pending-upgrade_olm-upgrading-operators[Manually approving a pending Operator upgrade]
36+
37+
include::modules/olm-pod-placement.adoc[leveloffset=+1]
38+
39+
.Additional resources
40+
41+
* Adding taints and tolerations xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-adding_nodes-scheduler-taints-tolerations[manually to nodes] or xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-adding-machineset_nodes-scheduler-taints-tolerations[with machine sets]
42+
* xref:../../nodes/scheduling/nodes-scheduler-node-selectors.adoc#nodes-scheduler-node-selectors-project_nodes-scheduler-node-selectors[Creating project-wide node selectors]
43+
* xref:../../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations-projects_nodes-scheduler-taints-tolerations[Creating a project with a node selector and toleration]
3644
endif::[]

0 commit comments

Comments
 (0)