From 3e2017a4ccce69111b81a5f0a36fd9d8ba76c162 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Wed, 18 Mar 2026 15:40:41 -0500 Subject: [PATCH] chore: add metrics service to prometheus component Include metrics_service.yaml in the prometheus kustomize Component so that deploying with the prometheus component provides both the ServiceMonitor and the matching Service for metrics scraping. Add app.kubernetes.io/name selector to Service and ServiceMonitor to uniquely target this operator's pods in shared namespaces. --- config/default/metrics_service.yaml | 1 + config/prometheus/kustomization.yaml | 1 + config/prometheus/metrics_service.yaml | 18 ++++++++++++++++++ config/prometheus/monitor.yaml | 1 + 4 files changed, 21 insertions(+) create mode 100644 config/prometheus/metrics_service.yaml diff --git a/config/default/metrics_service.yaml b/config/default/metrics_service.yaml index 13c1970..54f8134 100644 --- a/config/default/metrics_service.yaml +++ b/config/default/metrics_service.yaml @@ -15,3 +15,4 @@ spec: targetPort: 8443 selector: control-plane: controller-manager + app.kubernetes.io/name: workload-operator diff --git a/config/prometheus/kustomization.yaml b/config/prometheus/kustomization.yaml index 02c2c54..fa2b701 100644 --- a/config/prometheus/kustomization.yaml +++ b/config/prometheus/kustomization.yaml @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component resources: - monitor.yaml + - metrics_service.yaml diff --git a/config/prometheus/metrics_service.yaml b/config/prometheus/metrics_service.yaml new file mode 100644 index 0000000..54f8134 --- /dev/null +++ b/config/prometheus/metrics_service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + control-plane: controller-manager + app.kubernetes.io/name: workload-operator + app.kubernetes.io/managed-by: kustomize + name: controller-manager-metrics-service + namespace: system +spec: + ports: + - name: https + port: 8443 + protocol: TCP + targetPort: 8443 + selector: + control-plane: controller-manager + app.kubernetes.io/name: workload-operator diff --git a/config/prometheus/monitor.yaml b/config/prometheus/monitor.yaml index 15157ab..1e26e07 100644 --- a/config/prometheus/monitor.yaml +++ b/config/prometheus/monitor.yaml @@ -28,3 +28,4 @@ spec: selector: matchLabels: control-plane: controller-manager + app.kubernetes.io/name: workload-operator