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
148 changes: 66 additions & 82 deletions modules/monitoring-configuring-a-persistent-volume-claim.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,147 +3,131 @@
// * observability/monitoring/configuring-the-monitoring-stack.adoc

:_mod-docs-content-type: PROCEDURE
[id="configuring-a-persistent-volume-claim_{context}"]

= Configuring a persistent volume claim
// The ultimate solution DOES NOT NEED separate IDs, it is just needed for now so that the tests will not break

// tag::CPM[]
[id="configuring-a-persistent-volume-claim-cpm_{context}"]
= Configuring a persistent volume claim for core platform monitoring
// end::CPM[]

// tag::UWM[]
[id="configuring-a-persistent-volume-claim-uwm_{context}"]
= Configuring a persistent volume claim for monitoring of 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
:component: prometheusK8s
// end::CPM[]
// tag::UWM[]
:configmap-name: user-workload-monitoring-config
:namespace-name: openshift-user-workload-monitoring
:component: thanosRuler
// end::UWM[]

To use a persistent volume (PV) for monitoring components, you must configure a persistent volume claim (PVC).

.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.
// 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[]
// end::UWM[]
* You have installed the OpenShift CLI (`oc`).

.Procedure

. Edit the `ConfigMap` object:
ifndef::openshift-dedicated,openshift-rosa[]
** *To configure a PVC for a component that monitors core {product-title} projects*:
.. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project:
. Edit the `{configmap-name}` config map in the `{namespace-name}` project:
+
[source,terminal]
[source,terminal,subs="attributes+"]
----
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
$ oc -n {namespace-name} edit configmap {configmap-name}
----

.. Add your PVC configuration for the component under `data/config.yaml`:
. Add your PVC configuration for the component under `data/config.yaml`:
+
[source,yaml]
[source,yaml,subs="attributes+"]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-monitoring-config
namespace: openshift-monitoring
name: {configmap-name}
namespace: {namespace-name}
data:
config.yaml: |
<component>: #<1>
<component>: # <1>
volumeClaimTemplate:
spec:
storageClassName: <storage_class> #<2>
storageClassName: <storage_class> # <2>
resources:
requests:
storage: <amount_of_storage> #<3>
storage: <amount_of_storage> # <3>
----
<1> Specify the core monitoring component for which you want to configure the PVC.
<1> Specify the monitoring component for which you want to configure the PVC.
<2> Specify an existing storage class. If a storage class is not specified, the default storage class is used.
<3> Specify the amount of required storage.
+
See the link:https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims[Kubernetes documentation on PersistentVolumeClaims] for information on how to specify `volumeClaimTemplate`.
+
The following example configures a PVC that claims persistent storage for the Prometheus instance that monitors core {product-title} components:
The following example configures a PVC that claims persistent storage for
// tag::CPM[]
Prometheus:
// end::CPM[]
// tag::UWM[]
Thanos Ruler:
// end::UWM[]
+
[source,yaml]
.Example PVC configuration
[source,yaml,subs="attributes+"]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-monitoring-config
namespace: openshift-monitoring
name: {configmap-name}
namespace: {namespace-name}
data:
config.yaml: |
prometheusK8s:
{component}:
volumeClaimTemplate:
spec:
storageClassName: my-storage-class
resources:
requests:
# tag::CPM[]
storage: 40Gi
----

** *To configure a PVC for 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]
----
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
----

.. Add your PVC configuration for the component under `data/config.yaml`:
+
[source,yaml]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: user-workload-monitoring-config
namespace: openshift-user-workload-monitoring
data:
config.yaml: |
<component>: #<1>
volumeClaimTemplate:
spec:
storageClassName: <storage_class> #<2>
resources:
requests:
storage: <amount_of_storage> #<3>
----
<1> Specify the component for user-defined monitoring for which you want to configure the PVC.
<2> Specify an existing storage class. If a storage class is not specified, the default storage class is used.
<3> Specify the amount of required storage.
+
See the link:https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims[Kubernetes documentation on PersistentVolumeClaims] for information on how to specify `volumeClaimTemplate`.
+
The following example configures a PVC that claims persistent storage for Thanos Ruler:
+
[source,yaml]
----
apiVersion: v1
kind: ConfigMap
metadata:
name: user-workload-monitoring-config
namespace: openshift-user-workload-monitoring
data:
config.yaml: |
thanosRuler:
volumeClaimTemplate:
spec:
storageClassName: my-storage-class
resources:
requests:
# end::CPM[]
# tag::UWM[]
storage: 10Gi
# end::UWM[]
----
// tag::UWM[]
+
[NOTE]
====
Storage requirements for the `thanosRuler` component depend on the number of rules that are evaluated and how many samples each rule generates.
====
// end::UWM[]

. Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed and the new storage configuration is applied.
+
[WARNING]
====
When you update the config map with a PVC configuration, the affected `StatefulSet` object is recreated, resulting in a temporary service outage.
====

// Unset the source code block attributes just to be safe.
:!configmap-name:
:!namespace-name:
:!component:
Loading