From d952eeadc8112fead3fe653539c0f244ce91ee5a Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Thu, 16 Nov 2023 17:20:54 +0100 Subject: [PATCH] Rename ServiceMonitors to not get deleted by operator We create our own ServiceMonitor resources, since the argocd-operator doesn't support creating ServiceMonitors without also deploying a Prometheus instance. However, the operator will delete any ServiceMonitor which matches the name that it would generate for its managed ServiceMonitors if the Prometheus component is disabled, cf. https://github.com/argoproj-labs/argocd-operator/blob/17064c9b310785ab145747a367f7deb5507a572e/controllers/argocd/prometheus.go#L129-L136 This causes the component-managed ServiceMonitors to get deleted from time to time, and they get recreated after a while by an ArgoCD resync. This commit circumvents the issue by renaming the component-managed ServiceMonitors so they don't get deleted by the operator. --- component/monitoring.libsonnet | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/component/monitoring.libsonnet b/component/monitoring.libsonnet index 56c0067f..c5d9e62c 100644 --- a/component/monitoring.libsonnet +++ b/component/monitoring.libsonnet @@ -104,8 +104,10 @@ local promEnable = function(obj) ; [ - promEnable(serviceMonitor('syn-argocd-metrics')), - promEnable(serviceMonitor('syn-argocd-server-metrics')), - promEnable(serviceMonitor('syn-argocd-repo-server')), + // We explicitly select names for the service monitors which don't match the + // operator-generated names for instance syn-argocd + promEnable(serviceMonitor('syn-component-argocd-metrics')), + promEnable(serviceMonitor('syn-component-argocd-server-metrics')), + promEnable(serviceMonitor('syn-component-argocd-repo-server')), promEnable(alert_rules), ] + if params.monitoring.dashboards then [ grafana_dashboard ] else []