Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,112 +3,105 @@
// * observability/monitoring/configuring-the-monitoring-stack.adoc

:_mod-docs-content-type: PROCEDURE
[id="moving-monitoring-components-to-different-nodes_{context}"]
= Moving monitoring components to different nodes

ifndef::openshift-dedicated,openshift-rosa[]
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.
// The final solution DOES NOT NEED separate IDs, it is just needed for now so that the tests will not break

// tag::CPM[]
[id="moving-monitoring-components-to-different-nodes-cpm_{context}"]
= Moving monitoring components to different nodes for core platform monitoring
// end::CPM[]

// tag::UWM[]
[id="moving-monitoring-components-to-different-nodes-uwm_{context}"]
= Moving monitoring components to different nodes for monitoring for user-defined projects
// end::UWM[]

// Set attributes to distinguish between cluster monitoring example (core platform monitoring - CPM) and user workload monitoring (UWM) examples.
// tag::CPM[]
:configmap-name: cluster-monitoring-config
:namespace-name: openshift-monitoring
// end::CPM[]
// tag::UWM[]
:configmap-name: user-workload-monitoring-config
:namespace-name: openshift-user-workload-monitoring
// end::UWM[]

// tag::CPM[]
To specify the nodes in your cluster on which monitoring stack components will run, configure the `nodeSelector` constraint for the components in the `cluster-monitoring-config` config map to match labels assigned to the nodes.

[NOTE]
====
You cannot add a node selector constraint directly to an existing scheduled pod.
====
endif::openshift-dedicated,openshift-rosa[]
// end::CPM[]

ifdef::openshift-dedicated,openshift-rosa[]
You can move any of the components that monitor workloads for user-defined projects to specific worker nodes. It is not permitted to move components to control plane or infrastructure nodes.
endif::openshift-dedicated,openshift-rosa[]
// tag::UWM[]
You can move any of the components that monitor workloads for user-defined projects to specific worker nodes.

[WARNING]
====
It is not permitted to move components to control plane or infrastructure nodes.
====
// end::UWM[]

.Prerequisites

// tag::CPM[]
* You have access to the cluster as a user with the `cluster-admin` cluster role.
* You have created the `cluster-monitoring-config` `ConfigMap` object.
* You have installed the OpenShift CLI (`oc`).
// end::CPM[]

// tag::UWM[]
ifndef::openshift-dedicated,openshift-rosa[]
* *If you are configuring core {product-title} monitoring components*:
** You have access to the cluster as a user with the `cluster-admin` cluster role.
** You have created the `cluster-monitoring-config` `ConfigMap` object.
* *If you are configuring components that monitor user-defined projects*:
** You have access to the cluster as a user with the `cluster-admin` cluster role or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project.
** A cluster administrator has enabled monitoring for user-defined projects.
* You have access to the cluster as a user with the `cluster-admin` cluster role or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project.
* A cluster administrator has enabled monitoring for user-defined projects.
endif::openshift-dedicated,openshift-rosa[]
ifdef::openshift-dedicated,openshift-rosa[]
* You have access to the cluster as a user with the `dedicated-admin` role.
* The `user-workload-monitoring-config` `ConfigMap` object exists. This object is created by default when the cluster is created.
endif::openshift-dedicated,openshift-rosa[]
* You have installed the OpenShift CLI (`oc`).
// end::UWM[]

.Procedure

. If you have not done so yet, add a label to the nodes on which you want to run the monitoring components:
+
[source,terminal]
----
$ oc label nodes <node-name> <node-label>
----
. Edit the `ConfigMap` object:
ifndef::openshift-dedicated,openshift-rosa[]
** *To move a component that monitors core {product-title} projects*:

.. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project:
+
[source,terminal]
----
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
$ oc label nodes <node_name> <node_label> <1>
----
<1> Replace `<node_name>` with the name of the node where you want to add the label.
Replace `<node_label>` with the name of the wanted label.

.. Specify the node labels for the `nodeSelector` constraint for the component under `data/config.yaml`:
. Edit the `{configmap-name}` `ConfigMap` object in the `{namespace-name}` project:
+
[source,yaml]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-monitoring-config
namespace: openshift-monitoring
data:
config.yaml: |
<component>: <1>
nodeSelector:
<node-label-1> <2>
<node-label-2> <3>
<...>
----
<1> Substitute `<component>` with the appropriate monitoring stack component name.
<2> Substitute `<node-label-1>` with the label you added to the node.
<3> Optional: Specify additional labels.
If you specify additional labels, the pods for the component are only scheduled on the nodes that contain all of the specified labels.
+
[NOTE]
====
If monitoring components remain in a `Pending` state after configuring the `nodeSelector` constraint, check the pod events for errors relating to taints and tolerations.
====

** *To move a component that monitors user-defined projects*:
endif::openshift-dedicated,openshift-rosa[]

.. Edit the `user-workload-monitoring-config` `ConfigMap` object in the `openshift-user-workload-monitoring` project:
+
[source,terminal]
[source,terminal,subs="attributes+"]
----
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n {namespace-name} edit configmap {configmap-name}
----

.. Specify the node labels for the `nodeSelector` constraint for the component under `data/config.yaml`:
. Specify the node labels for the `nodeSelector` constraint for the component under `data/config.yaml`:
+
[source,yaml]
[source,yaml,subs="attributes+"]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: user-workload-monitoring-config
namespace: openshift-user-workload-monitoring
name: {configmap-name}
namespace: {namespace-name}
data:
config.yaml: |
<component>: <1>
# ...
<component>: #<1>
nodeSelector:
<node-label-1> <2>
<node-label-2> <3>
<...>
<node_label_1> #<2>
<node_label_2> #<3>
# ...
----
<1> Substitute `<component>` with the appropriate monitoring stack component name.
<2> Substitute `<node-label-1>` with the label you added to the node.
<2> Substitute `<node_label_1>` with the label you added to the node.
<3> Optional: Specify additional labels.
If you specify additional labels, the pods for the component are only scheduled on the nodes that contain all of the specified labels.
+
Expand Down
10 changes: 9 additions & 1 deletion observability/monitoring/configuring-the-monitoring-stack.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,16 @@ endif::openshift-dedicated,openshift-rosa[]
* xref:../../observability/monitoring/configuring-the-monitoring-stack.adoc#using-pod-topology-spread-constraints-for-monitoring_configuring-the-monitoring-stack[Using pod topology spread constraints for monitoring]
* link:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector[Kubernetes documentation about node selectors]

include::modules/monitoring-moving-monitoring-components-to-different-nodes.adoc[leveloffset=+2]
// This following ifndef causes the first procedure NOT to show up in ROSA/OSD builds, only in the OCP build
// The final solution WILL NOT need those ifdef statements
// The module should only include core platform monitoring
ifndef::openshift-dedicated,openshift-rosa[]
include::modules/monitoring-moving-monitoring-components-to-different-nodes.adoc[leveloffset=+2,tags=**;CPM;!UWM]
endif::openshift-dedicated,openshift-rosa[]

// The following module shows in all builds.
// The module should only include monitoring for user-defined projects
include::modules/monitoring-moving-monitoring-components-to-different-nodes.adoc[leveloffset=+2,tags=**;!CPM;UWM]

[role="_additional-resources"]
.Additional resources
Expand Down