Skip to content

Commit f4bb8ef

Browse files
committed
RHDEVDOCS-4967-update-nodeselector-example-for-moving-monitoring-components
1 parent b6acfde commit f4bb8ef

3 files changed

+79
-102
lines changed

modules/monitoring-moving-monitoring-components-to-different-nodes.adoc

Lines changed: 37 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,42 @@
66
[id="moving-monitoring-components-to-different-nodes_{context}"]
77
= Moving monitoring components to different nodes
88

9-
You can move any of the monitoring stack components to specific nodes.
9+
To specify the nodes in your cluster on which monitoring stack components will run, configure the `nodeSelector` constraint in the component's `ConfigMap` object to match labels assigned to the nodes.
10+
11+
[NOTE]
12+
====
13+
You cannot add a node selector constraint directly to an existing scheduled pod.
14+
====
1015

1116
.Prerequisites
1217

1318
* *If you are configuring core {product-title} monitoring components*:
1419
** You have access to the cluster as a user with the `cluster-admin` role.
1520
** You have created the `cluster-monitoring-config` `ConfigMap` object.
1621
* *If you are configuring components that monitor user-defined projects*:
17-
** You have access to the cluster as a user with the `cluster-admin` role, or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project.
22+
** You have access to the cluster as a user with the `cluster-admin` role or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project.
1823
** You have created the `user-workload-monitoring-config` `ConfigMap` object.
1924
* You have installed the OpenShift CLI (`oc`).
2025
2126
.Procedure
2227

28+
. If you have not done so yet, add a label to the nodes on which you want to run the monitoring components:
29+
+
30+
[source,terminal]
31+
----
32+
$ oc label nodes <node-name> <node-label>
33+
----
2334
. Edit the `ConfigMap` object:
2435
** *To move a component that monitors core {product-title} projects*:
36+
2537
.. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project:
2638
+
2739
[source,terminal]
2840
----
2941
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
3042
----
3143

32-
.. Specify the `nodeSelector` constraint for the component under `data/config.yaml`:
44+
.. Specify the node labels for the `nodeSelector` constraint for the component under `data/config.yaml`:
3345
+
3446
[source,yaml]
3547
----
@@ -40,77 +52,32 @@ metadata:
4052
namespace: openshift-monitoring
4153
data:
4254
config.yaml: |
43-
<component>:
55+
<component>: <1>
4456
nodeSelector:
45-
<node_key>: <node_value>
46-
<node_key>: <node_value>
57+
<node-label-1> <2>
58+
<node-label-2> <3>
4759
<...>
4860
----
49-
+
50-
Substitute `<component>` accordingly and substitute `<node_key>: <node_value>` with the map of key-value pairs that specifies a group of destination nodes. Often, only a single key-value pair is used.
51-
+
52-
The component can only run on nodes that have each of the specified key-value pairs as labels. The nodes can have additional labels as well.
53-
+
54-
[IMPORTANT]
55-
====
56-
Many of the monitoring components are deployed by using multiple pods across different nodes in the cluster to maintain high availability. When moving monitoring components to labeled nodes, ensure that enough matching nodes are available to maintain resilience for the component. If only one label is specified, ensure that enough nodes contain that label to distribute all of the pods for the component across separate nodes. Alternatively, you can specify multiple labels each relating to individual nodes.
57-
====
61+
<1> Substitute `<component>` with the appropriate monitoring stack component name.
62+
<2> Substitute `<node-label-1>` with the label you added to the node.
63+
<3> Optional: Specify additional labels.
64+
If you specify additional labels, the pods for the component are only scheduled on the nodes that contain all of the specified labels.
5865
+
5966
[NOTE]
6067
====
61-
If monitoring components remain in a `Pending` state after configuring the `nodeSelector` constraint, check the pod logs for errors relating to taints and tolerations.
68+
If monitoring components remain in a `Pending` state after configuring the `nodeSelector` constraint, check the pod events for errors relating to taints and tolerations.
6269
====
63-
+
64-
For example, to move monitoring components for core {product-title} projects to specific nodes that are labeled `nodename: controlplane1`, `nodename: worker1`, `nodename: worker2`, and `nodename: worker2`, use:
65-
+
66-
[source,yaml,subs=quotes]
67-
----
68-
apiVersion: v1
69-
kind: ConfigMap
70-
metadata:
71-
name: cluster-monitoring-config
72-
namespace: openshift-monitoring
73-
data:
74-
config.yaml: |
75-
prometheusOperator:
76-
nodeSelector:
77-
nodename: controlplane1
78-
prometheusK8s:
79-
nodeSelector:
80-
nodename: worker1
81-
nodename: worker2
82-
alertmanagerMain:
83-
nodeSelector:
84-
nodename: worker1
85-
nodename: worker2
86-
kubeStateMetrics:
87-
nodeSelector:
88-
nodename: worker1
89-
telemeterClient:
90-
nodeSelector:
91-
nodename: worker1
92-
k8sPrometheusAdapter:
93-
nodeSelector:
94-
nodename: worker1
95-
nodename: worker2
96-
openshiftStateMetrics:
97-
nodeSelector:
98-
nodename: worker1
99-
thanosQuerier:
100-
nodeSelector:
101-
nodename: worker1
102-
nodename: worker2
103-
----
10470

10571
** *To move a component that monitors user-defined projects*:
72+
10673
.. Edit the `user-workload-monitoring-config` `ConfigMap` object in the `openshift-user-workload-monitoring` project:
10774
+
10875
[source,terminal]
10976
----
11077
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
11178
----
11279

113-
.. Specify the `nodeSelector` constraint for the component under `data/config.yaml`:
80+
.. Specify the node labels for the `nodeSelector` constraint for the component under `data/config.yaml`:
11481
+
11582
[source,yaml]
11683
----
@@ -121,52 +88,24 @@ metadata:
12188
namespace: openshift-user-workload-monitoring
12289
data:
12390
config.yaml: |
124-
<component>:
91+
<component>: <1>
12592
nodeSelector:
126-
<node_key>: <node_value>
127-
<node_key>: <node_value>
93+
<node-label-1> <2>
94+
<node-label-2> <3>
12895
<...>
12996
----
130-
+
131-
Substitute `<component>` accordingly and substitute `<node_key>: <node_value>` with the map of key-value pairs that specifies the destination nodes. Often, only a single key-value pair is used.
132-
+
133-
The component can only run on nodes that have each of the specified key-value pairs as labels. The nodes can have additional labels as well.
134-
+
135-
[IMPORTANT]
136-
====
137-
Many of the monitoring components are deployed by using multiple pods across different nodes in the cluster to maintain high availability. When moving monitoring components to labeled nodes, ensure that enough matching nodes are available to maintain resilience for the component. If only one label is specified, ensure that enough nodes contain that label to distribute all of the pods for the component across separate nodes. Alternatively, you can specify multiple labels each relating to individual nodes.
138-
====
97+
<1> Substitute `<component>` with the appropriate monitoring stack component name.
98+
<2> Substitute `<node-label-1>` with the label you added to the node.
99+
<3> Optional: Specify additional labels.
100+
If you specify additional labels, the pods for the component are only scheduled on the nodes that contain all of the specified labels.
139101
+
140102
[NOTE]
141103
====
142-
If monitoring components remain in a `Pending` state after configuring the `nodeSelector` constraint, check the pod logs for errors relating to taints and tolerations.
104+
If monitoring components remain in a `Pending` state after configuring the `nodeSelector` constraint, check the pod events for errors relating to taints and tolerations.
143105
====
144-
+
145-
For example, to move monitoring components for user-defined projects to specific worker nodes labeled `nodename: worker1`, `nodename: worker2`, and `nodename: worker2`, use:
146-
+
147-
[source,yaml,subs=quotes]
148-
----
149-
apiVersion: v1
150-
kind: ConfigMap
151-
metadata:
152-
name: user-workload-monitoring-config
153-
namespace: openshift-user-workload-monitoring
154-
data:
155-
config.yaml: |
156-
prometheusOperator:
157-
nodeSelector:
158-
nodename: worker1
159-
prometheus:
160-
nodeSelector:
161-
nodename: worker1
162-
nodename: worker2
163-
thanosRuler:
164-
nodeSelector:
165-
nodename: worker1
166-
nodename: worker2
167-
----
168106

169-
. Save the file to apply the changes. The components affected by the new configuration are moved to the new nodes automatically.
107+
. Save the file to apply the changes.
108+
The components specified in the new configuration are moved to the new nodes automatically.
170109
+
171110
[NOTE]
172111
====
@@ -175,5 +114,6 @@ Configurations applied to the `user-workload-monitoring-config` `ConfigMap` obje
175114
+
176115
[WARNING]
177116
====
178-
When changes are saved to a monitoring config map, the pods and other resources in the related project might be redeployed. The running monitoring processes in that project might also be restarted.
117+
When you save changes to a monitoring config map, the pods and other resources in the project might be redeployed.
118+
The running monitoring processes in that project might also restart.
179119
====
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/configuring-the-monitoring-stack.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="using-node-selectors-to-move-monitoring-components_{context}"]
7+
= Using node selectors to move monitoring components
8+
9+
By using the `nodeSelector` constraint with labeled nodes, you can move any of the monitoring stack components to specific nodes.
10+
By doing so, you can control the placement and distribution of the monitoring components across a cluster.
11+
12+
By controlling placement and distribution of monitoring components, you can optimize system resource use, improve performance, and segregate workloads based on specific requirements or policies.
13+
14+
[id="how-node-selectors-work-with-other-constraints_{context}"]
15+
== How node selectors work with other constraints
16+
17+
18+
If you move monitoring components by using node selector constraints, be aware that other constraints to control pod scheduling might exist for a cluster:
19+
20+
* Topology spread constraints might be in place to control pod placement.
21+
* Hard anti-affinity rules are in place for Prometheus, Thanos Querier, Alertmanager, and other monitoring components to ensure that multiple pods for these components are always spread across different nodes and are therefore always highly available.
22+
23+
When scheduling pods onto nodes, the pod scheduler tries to satisfy all existing constraints when determining pod placement.
24+
That is, all constraints compound when the pod scheduler determines which pods will be placed on which nodes.
25+
26+
Therefore, if you configure a node selector constraint but existing constraints cannot all be satisfied, the pod scheduler cannot match all constraints and will not schedule a pod for placement onto a node.
27+
28+
To maintain resilience and high availability for monitoring components, ensure that enough nodes are available and match all constraints when you configure a node selector constraint to move a component.

monitoring/configuring-the-monitoring-stack.adoc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,25 @@ include::modules/monitoring-configuring-the-monitoring-stack.adoc[leveloffset=+1
4646
include::modules/monitoring-configurable-monitoring-components.adoc[leveloffset=+1]
4747

4848
// Moving monitoring components to different nodes
49-
include::modules/monitoring-moving-monitoring-components-to-different-nodes.adoc[leveloffset=+1]
49+
include::modules/monitoring-using-node-selectors-to-move-monitoring-components.adoc[leveloffset=+1]
50+
[role="_additional-resources"]
51+
.Additional resources
52+
53+
* xref:../nodes/nodes/nodes-nodes-working.adoc#nodes-nodes-working-updating_nodes-nodes-working[Understanding how to update labels on nodes]
54+
* xref:../nodes/scheduling/nodes-scheduler-node-selectors.adoc#nodes-scheduler-node-selectors[Placing pods on specific nodes using node selectors]
55+
* xref:../nodes/scheduling/nodes-scheduler-pod-affinity.adoc[Placing pods relative to other pods using affinity and anti-affinity rules]
56+
* xref:../nodes/scheduling/nodes-scheduler-pod-topology-spread-constraints.adoc[Controlling pod placement by using pod topology spread constraints]
57+
* xref:../monitoring/configuring-the-monitoring-stack.adoc#configuring_pod_topology_spread_constraintsfor_monitoring_configuring-the-monitoring-stack[Configuring pod topology spread constraints for monitoring]
58+
* link:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector[Kubernetes documentation about node selectors]
59+
60+
include::modules/monitoring-moving-monitoring-components-to-different-nodes.adoc[leveloffset=+2]
61+
5062

5163
[role="_additional-resources"]
5264
.Additional resources
5365

5466
* See xref:../monitoring/configuring-the-monitoring-stack.adoc#preparing-to-configure-the-monitoring-stack[Preparing to configure the monitoring stack] for steps to create monitoring config maps
5567
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
56-
* xref:../nodes/nodes/nodes-nodes-working.adoc#nodes-nodes-working-updating_nodes-nodes-working[Understanding how to update labels on nodes]
57-
* xref:../nodes/scheduling/nodes-scheduler-node-selectors.adoc#nodes-scheduler-node-selectors[Placing pods on specific nodes using node selectors]
58-
* See the link:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector[Kubernetes documentation] for details on the `nodeSelector` constraint
5968

6069
// Assigning tolerations to monitoring components
6170
include::modules/monitoring-assigning-tolerations-to-monitoring-components.adoc[leveloffset=+1]
@@ -124,7 +133,7 @@ include::modules/monitoring-choosing-a-metrics-collection-profile.adoc[leveloffs
124133
.Additional resources
125134

126135
* See xref:../monitoring/managing-metrics.adoc#viewing-a-list-of-available-metrics_managing-metrics[Viewing a list of available metrics] for steps to view a list of metrics being collected for a cluster.
127-
* See xref:../nodes/clusters/nodes-cluster-enabling-features.adoc[Enabling features using feature gates] for steps to enable Technology Preview features.
136+
* See xref:../nodes/clusters/nodes-cluster-enabling-features.adoc[Enabling features using feature gates] for steps to enable Technology Preview features.
128137

129138
// Managing scrape sample limits for user-defined projects
130139
include::modules/monitoring-limiting-scrape-samples-in-user-defined-projects.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)