From 9bad2769c36858f25dd472de26e864a54e833ae2 Mon Sep 17 00:00:00 2001 From: Starttoaster Date: Fri, 25 Oct 2024 11:14:31 -0700 Subject: [PATCH] Add working ServiceMonitor config to release uploads (#199) --- Makefile | 1 + config/prometheus/kustomization.yaml | 2 ++ config/prometheus/monitor.yaml | 24 +++++++----------------- docs/install.md | 10 ++++++++++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index f78868e..a8d98e3 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ release: manifests kustomize ## Build CRD and Operator manifests with kustomize. mkdir -p release/ $(KUSTOMIZE) build config/crd > release/crd.yaml $(KUSTOMIZE) build config/default > release/manager.yaml + $(KUSTOMIZE) build config/prometheus > release/monitor.yaml # If you wish to build the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. diff --git a/config/prometheus/kustomization.yaml b/config/prometheus/kustomization.yaml index ed13716..e7c38e3 100644 --- a/config/prometheus/kustomization.yaml +++ b/config/prometheus/kustomization.yaml @@ -1,2 +1,4 @@ +namespace: chia-operator-system +namePrefix: chia-operator- resources: - monitor.yaml diff --git a/config/prometheus/monitor.yaml b/config/prometheus/monitor.yaml index ff800f6..a7046fb 100644 --- a/config/prometheus/monitor.yaml +++ b/config/prometheus/monitor.yaml @@ -1,26 +1,16 @@ - -# Prometheus Monitor Service (Metrics) apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: servicemonitor - app.kubernetes.io/instance: controller-manager-metrics-monitor - app.kubernetes.io/component: metrics - app.kubernetes.io/created-by: chia-operator - app.kubernetes.io/part-of: chia-operator - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-monitor + name: manager-metrics namespace: system spec: endpoints: - - path: /metrics - port: https - scheme: https - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - tlsConfig: - insecureSkipVerify: true + - interval: 30s + path: /metrics + port: metrics + namespaceSelector: + matchNames: + - chia-operator-system selector: matchLabels: control-plane: controller-manager diff --git a/docs/install.md b/docs/install.md index bb3903a..4180fe5 100644 --- a/docs/install.md +++ b/docs/install.md @@ -18,6 +18,16 @@ Install the latest controller manager: kubectl apply -f https://github.com/Chia-Network/chia-operator/releases/latest/download/manager.yaml ``` +### Prometheus metrics (Optional) + +If you have the Prometheus Operator installed in your cluster and would like to use the bundled ServiceMonitor to scrape chia-operator metrics: + +```bash +kubectl apply -f https://github.com/Chia-Network/chia-operator/releases/latest/download/monitor.yaml +``` + +This ServiceMonitor is installed in the same namespace as chia-operator, so it will only work in Prometheus Operator configurations that can load ServiceMonitors from any namespace, and also don't have any ServiceMonitorSelectors set. + ## Using kustomize Clone this repository (and change to its directory):