From 3737457b0fd8e3f05da8aec80da86911be24fcf6 Mon Sep 17 00:00:00 2001
From: Nick Kampe <Kampe@users.noreply.github.com>
Date: Wed, 16 Aug 2023 02:01:43 -0500
Subject: [PATCH] feat(argo-rollouts): update servicemonitor.yaml to allow for
 namespace to be set (#2222)

* Update servicemonitor.yaml to allow for namespace to be set

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

* Update README.md

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

* Update values.yaml

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

* Update Chart.yaml

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

* Update Chart.yaml

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

* Alphabetized namespace addition in README

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>

---------

Signed-off-by: Nick Kampe <Kampe@users.noreply.github.com>
---
 charts/argo-rollouts/Chart.yaml                               | 4 ++--
 charts/argo-rollouts/README.md                                | 1 +
 charts/argo-rollouts/templates/controller/servicemonitor.yaml | 2 +-
 charts/argo-rollouts/values.yaml                              | 2 ++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/charts/argo-rollouts/Chart.yaml b/charts/argo-rollouts/Chart.yaml
index 0bf8dfcb..2aba36f1 100644
--- a/charts/argo-rollouts/Chart.yaml
+++ b/charts/argo-rollouts/Chart.yaml
@@ -2,7 +2,7 @@ apiVersion: v2
 appVersion: v1.5.1
 description: A Helm chart for Argo Rollouts
 name: argo-rollouts
-version: 2.31.5
+version: 2.31.6
 home: https://github.com/argoproj/argo-helm
 icon: https://argoproj.github.io/argo-rollouts/assets/logo.png
 keywords:
@@ -19,4 +19,4 @@ annotations:
     url: https://argoproj.github.io/argo-helm/pgp_keys.asc
   artifacthub.io/changes: |
     - kind: added
-      description: Add CI example for extra objects
+      description: Add ability to set namespace on ServiceMonitor resource
diff --git a/charts/argo-rollouts/README.md b/charts/argo-rollouts/README.md
index 4e028779..b9198998 100644
--- a/charts/argo-rollouts/README.md
+++ b/charts/argo-rollouts/README.md
@@ -98,6 +98,7 @@ For full list of changes please check ArtifactHub [changelog].
 | controller.metrics.serviceMonitor.additionalLabels | object | `{}` | Labels to be added to the ServiceMonitor |
 | controller.metrics.serviceMonitor.enabled | bool | `false` | Enable a prometheus ServiceMonitor |
 | controller.metrics.serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion |
+| controller.metrics.serviceMonitor.namespace | string | `""` | Namespace to be used for the ServiceMonitor |
 | controller.metrics.serviceMonitor.relabelings | list | `[]` | RelabelConfigs to apply to samples before scraping |
 | controller.nodeSelector | object | `{}` | [Node selector] |
 | controller.pdb.annotations | object | `{}` | Annotations to be added to controller [Pod Disruption Budget] |
diff --git a/charts/argo-rollouts/templates/controller/servicemonitor.yaml b/charts/argo-rollouts/templates/controller/servicemonitor.yaml
index 62713764..d7ab901e 100644
--- a/charts/argo-rollouts/templates/controller/servicemonitor.yaml
+++ b/charts/argo-rollouts/templates/controller/servicemonitor.yaml
@@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1
 kind: ServiceMonitor
 metadata:
   name: {{ include "argo-rollouts.fullname" . }}
-  namespace: {{ .Release.Namespace | quote }}
+  namespace: {{ default .Release.Namespace .Values.controller.metrics.serviceMonitor.namespace | quote }}
   labels:
     app.kubernetes.io/component: {{ .Values.controller.component }}
     {{- include "argo-rollouts.labels" . | nindent 4 }}
diff --git a/charts/argo-rollouts/values.yaml b/charts/argo-rollouts/values.yaml
index f9d8e1cf..b711ee37 100644
--- a/charts/argo-rollouts/values.yaml
+++ b/charts/argo-rollouts/values.yaml
@@ -132,6 +132,8 @@ controller:
     serviceMonitor:
       # -- Enable a prometheus ServiceMonitor
       enabled: false
+      # -- Namespace to be used for the ServiceMonitor
+      namespace: ""
       # -- Labels to be added to the ServiceMonitor
       additionalLabels: {}
       # -- Annotations to be added to the ServiceMonitor