From f7738d74342d2e767a3b8f47451f1f057fa01fa0 Mon Sep 17 00:00:00 2001
From: Francesco Ciocchetti <primeroznl@gmail.com>
Date: Tue, 4 Jan 2022 10:03:14 +0100
Subject: [PATCH] Set namespace to null for clusterwide resources and generate
 manifests

---
 jsonnet/kube-prometheus/components/prometheus.libsonnet | 8 ++++++--
 manifests/prometheus-clusterRole.yaml                   | 1 -
 manifests/prometheus-clusterRoleBinding.yaml            | 1 -
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/jsonnet/kube-prometheus/components/prometheus.libsonnet b/jsonnet/kube-prometheus/components/prometheus.libsonnet
index 365a3aff..c026ffec 100644
--- a/jsonnet/kube-prometheus/components/prometheus.libsonnet
+++ b/jsonnet/kube-prometheus/components/prometheus.libsonnet
@@ -146,7 +146,9 @@ function(params) {
   clusterRole: {
     apiVersion: 'rbac.authorization.k8s.io/v1',
     kind: 'ClusterRole',
-    metadata: p._metadata,
+    metadata: p._metadata {
+      namespace:: null,
+    },
     rules: [
       {
         apiGroups: [''],
@@ -194,7 +196,9 @@ function(params) {
   clusterRoleBinding: {
     apiVersion: 'rbac.authorization.k8s.io/v1',
     kind: 'ClusterRoleBinding',
-    metadata: p._metadata,
+    metadata: p._metadata {
+      namespace:: null,
+    },
     roleRef: {
       apiGroup: 'rbac.authorization.k8s.io',
       kind: 'ClusterRole',
diff --git a/manifests/prometheus-clusterRole.yaml b/manifests/prometheus-clusterRole.yaml
index 1f1f6bbd..7bf33192 100644
--- a/manifests/prometheus-clusterRole.yaml
+++ b/manifests/prometheus-clusterRole.yaml
@@ -8,7 +8,6 @@ metadata:
     app.kubernetes.io/part-of: kube-prometheus
     app.kubernetes.io/version: 2.32.1
   name: prometheus-k8s
-  namespace: monitoring
 rules:
 - apiGroups:
   - ""
diff --git a/manifests/prometheus-clusterRoleBinding.yaml b/manifests/prometheus-clusterRoleBinding.yaml
index 89ec1fd3..4dabee82 100644
--- a/manifests/prometheus-clusterRoleBinding.yaml
+++ b/manifests/prometheus-clusterRoleBinding.yaml
@@ -8,7 +8,6 @@ metadata:
     app.kubernetes.io/part-of: kube-prometheus
     app.kubernetes.io/version: 2.32.1
   name: prometheus-k8s
-  namespace: monitoring
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: ClusterRole
-- 
GitLab