From 967fc244f38e9064f2b53eef39d3efa65f99d659 Mon Sep 17 00:00:00 2001 From: Eliska Romanova Date: Mon, 14 Oct 2024 14:22:58 +0200 Subject: [PATCH] OBSDOCS-1408: Make an example separation for Moving monitoring components to different nodes section --- ...itoring-components-to-different-nodes.adoc | 127 +++++++++--------- .../configuring-the-monitoring-stack.adoc | 10 +- 2 files changed, 69 insertions(+), 68 deletions(-) diff --git a/modules/monitoring-moving-monitoring-components-to-different-nodes.adoc b/modules/monitoring-moving-monitoring-components-to-different-nodes.adoc index fd865e3a7d38..a9005ad9e65a 100644 --- a/modules/monitoring-moving-monitoring-components-to-different-nodes.adoc +++ b/modules/monitoring-moving-monitoring-components-to-different-nodes.adoc @@ -3,36 +3,66 @@ // * 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 @@ -40,75 +70,38 @@ endif::openshift-dedicated,openshift-rosa[] + [source,terminal] ---- -$ oc label nodes ----- -. 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 <1> ---- +<1> Replace `` with the name of the node where you want to add the label. +Replace `` 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: | - : <1> - nodeSelector: - <2> - <3> - <...> ----- -<1> Substitute `` with the appropriate monitoring stack component name. -<2> Substitute `` 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: | - : <1> + # ... + : #<1> nodeSelector: - <2> - <3> - <...> + #<2> + #<3> + # ... ---- <1> Substitute `` with the appropriate monitoring stack component name. -<2> Substitute `` with the label you added to the node. +<2> Substitute `` 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. + diff --git a/observability/monitoring/configuring-the-monitoring-stack.adoc b/observability/monitoring/configuring-the-monitoring-stack.adoc index 61f4881b9518..c5a6595c7f54 100644 --- a/observability/monitoring/configuring-the-monitoring-stack.adoc +++ b/observability/monitoring/configuring-the-monitoring-stack.adoc @@ -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