From 14c46b80000d8686fb60fa0cc06e68906c358c7b Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Tue, 19 Sep 2023 15:26:40 +0200 Subject: [PATCH] mgr: adding support for prometheus endpoint configuration Using the new configuration parameters prometheusEndpoint and prometheusEndpointSSLVerify users can configure dashboard to point to their prometheus instance. closes: #12876 Signed-off-by: Redouane Kachach (cherry picked from commit c76393543687f0321e016ef633223ee433369f91) --- Documentation/CRDs/specification.md | 24 +++++++++++++++++++ .../Monitoring/ceph-monitoring.md | 21 ++++++++++++++++ .../charts/rook-ceph/templates/resources.yaml | 6 +++++ deploy/examples/cluster.yaml | 4 ++++ deploy/examples/crds.yaml | 6 +++++ pkg/apis/ceph.rook.io/v1/types.go | 6 +++++ pkg/operator/ceph/cluster/mgr/dashboard.go | 16 +++++++++++++ 7 files changed, 83 insertions(+) diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md index 912ac33be..c2120058b 100644 --- a/Documentation/CRDs/specification.md +++ b/Documentation/CRDs/specification.md @@ -4982,6 +4982,30 @@ bool

SSL determines whether SSL should be used

+ + +prometheusEndpoint
+ +string + + + +(Optional) +

Endpoint for the Prometheus host

+ + + + +prometheusEndpointSSLVerify
+ +bool + + + +(Optional) +

Whether to verify the ssl endpoint for prometheus. Set to false for a self-signed cert.

+ +

Device diff --git a/Documentation/Storage-Configuration/Monitoring/ceph-monitoring.md b/Documentation/Storage-Configuration/Monitoring/ceph-monitoring.md index b16fdfc6d..ec6ca53e1 100644 --- a/Documentation/Storage-Configuration/Monitoring/ceph-monitoring.md +++ b/Documentation/Storage-Configuration/Monitoring/ceph-monitoring.md @@ -63,6 +63,27 @@ Ensure that the Prometheus server pod gets created and advances to the `Running` kubectl -n rook-ceph get pod prometheus-rook-prometheus-0 ``` +### Dashboard config + +Configure the Prometheus endpoint so the dashboard can retrieve metrics from Prometheus with two settings: +- `prometheusEndpoint`: The url of the Prometheus instance +- `prometheusEndpointSSLVerify`: Whether SSL should be verified if the Prometheus server is using https + +The following command can be used to get the Prometheus url: + +```console +echo "http://$(kubectl -n rook-ceph -o jsonpath={.status.hostIP} get pod prometheus-rook-prometheus-0):30900" +``` + +Following is an example to configure the Prometheus endpoint in the CephCluster CR. + + ```YAML + spec: + dashboard: + prometheusEndpoint: http://192.168.61.204:30900 + prometheusEndpointSSLVerify: true + ``` + !!! note It is not recommended to consume storage from the Ceph cluster for Prometheus. If the Ceph cluster fails, Prometheus would become unresponsive and thus not alert you of the failure. diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 3046de7c9..ad4e7b4c0 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -974,6 +974,12 @@ spec: maximum: 65535 minimum: 0 type: integer + prometheusEndpoint: + description: Endpoint for the Prometheus host + type: string + prometheusEndpointSSLVerify: + description: Whether to verify the ssl endpoint for prometheus. Set to false for a self-signed cert. + type: boolean ssl: description: SSL determines whether SSL should be used type: boolean diff --git a/deploy/examples/cluster.yaml b/deploy/examples/cluster.yaml index d6b3aaa71..28a99549f 100644 --- a/deploy/examples/cluster.yaml +++ b/deploy/examples/cluster.yaml @@ -70,6 +70,10 @@ spec: # port: 8443 # serve the dashboard using SSL ssl: true + # The url of the Prometheus instance + # prometheusEndpoint: ://: + # Whether SSL should be verified if the Prometheus server is using https + # prometheusEndpointSSLVerify: false # enable prometheus alerting for cluster monitoring: # requires Prometheus to be pre-installed diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 469c5b658..1f6b85741 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -972,6 +972,12 @@ spec: maximum: 65535 minimum: 0 type: integer + prometheusEndpoint: + description: Endpoint for the Prometheus host + type: string + prometheusEndpointSSLVerify: + description: Whether to verify the ssl endpoint for prometheus. Set to false for a self-signed cert. + type: boolean ssl: description: SSL determines whether SSL should be used type: boolean diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 379d2a11a..1be7345f0 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -318,6 +318,12 @@ type DashboardSpec struct { // SSL determines whether SSL should be used // +optional SSL bool `json:"ssl,omitempty"` + // Endpoint for the Prometheus host + // +optional + PrometheusEndpoint string `json:"prometheusEndpoint,omitempty"` + // Whether to verify the ssl endpoint for prometheus. Set to false for a self-signed cert. + // +optional + PrometheusEndpointSSLVerify bool `json:"prometheusEndpointSSLVerify,omitempty"` } // MonitoringSpec represents the settings for Prometheus based Ceph monitoring diff --git a/pkg/operator/ceph/cluster/mgr/dashboard.go b/pkg/operator/ceph/cluster/mgr/dashboard.go index cd0478a85..ead1a152b 100644 --- a/pkg/operator/ceph/cluster/mgr/dashboard.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard.go @@ -129,6 +129,22 @@ func (c *Cluster) configureDashboardModuleSettings(daemonID string) (bool, error } hasChanged = hasChanged || changed + // Prometheus host end point + prometheusEndpoint := c.spec.Dashboard.PrometheusEndpoint + changed, err = monStore.SetIfChanged(daemonID, "mgr/dashboard/PROMETHEUS_API_HOST", prometheusEndpoint) + if err != nil { + return false, err + } + hasChanged = hasChanged || changed + + // Prometheus host end point ssl verify + prometheusEndpointSSLVerify := strconv.FormatBool(c.spec.Dashboard.PrometheusEndpointSSLVerify) + changed, err = monStore.SetIfChanged(daemonID, "mgr/dashboard/PROMETHEUS_API_SSL_VERIFY", prometheusEndpointSSLVerify) + if err != nil { + return false, err + } + hasChanged = hasChanged || changed + // server port port := strconv.Itoa(c.dashboardInternalPort()) changed, err = monStore.SetIfChanged(daemonID, "mgr/dashboard/server_port", port)