From 110b578a08a5457168e163bda6b58fc60d4323cf Mon Sep 17 00:00:00 2001 From: Karlis Akots Gribulis Date: Fri, 19 May 2023 20:39:49 +0300 Subject: [PATCH] add namespace to all resources Signed-off-by: Karlis Akots Gribulis --- charts/redisoperator/Chart.yaml | 2 +- charts/redisoperator/templates/_helpers.tpl | 7 +++++++ charts/redisoperator/templates/deployment.yaml | 1 + charts/redisoperator/templates/monitoring.yaml | 4 +++- charts/redisoperator/templates/private-registry.yaml | 1 + charts/redisoperator/templates/service-account.yaml | 3 ++- charts/redisoperator/templates/service.yaml | 1 + charts/redisoperator/values.yaml | 4 ++++ 8 files changed, 20 insertions(+), 3 deletions(-) diff --git a/charts/redisoperator/Chart.yaml b/charts/redisoperator/Chart.yaml index 57d1003ef..40c284a39 100644 --- a/charts/redisoperator/Chart.yaml +++ b/charts/redisoperator/Chart.yaml @@ -4,7 +4,7 @@ appVersion: 1.2.4 apiVersion: v1 description: A Helm chart for the Spotahome Redis Operator name: redis-operator -version: 3.2.8 +version: 3.2.9 home: https://github.com/spotahome/redis-operator keywords: - "golang" diff --git a/charts/redisoperator/templates/_helpers.tpl b/charts/redisoperator/templates/_helpers.tpl index 6c8ea6799..1fbfb51da 100644 --- a/charts/redisoperator/templates/_helpers.tpl +++ b/charts/redisoperator/templates/_helpers.tpl @@ -76,3 +76,10 @@ Create the name of the service account to use {{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} {{- end }} {{- end }} + +{{/* +Create the name of the namespace +*/}} +{{- define "chart.namespaceName" -}} +{{- default .Release.Namespace .Values.namespace }} +{{- end }} diff --git a/charts/redisoperator/templates/deployment.yaml b/charts/redisoperator/templates/deployment.yaml index 72c314145..fee902462 100644 --- a/charts/redisoperator/templates/deployment.yaml +++ b/charts/redisoperator/templates/deployment.yaml @@ -5,6 +5,7 @@ apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }} kind: Deployment metadata: name: {{ $fullName }} + namespace: {{ include "chart.namespaceName" . }} labels: {{- include "chart.labels" $data | nindent 4 }} {{- if .Values.annotations }} diff --git a/charts/redisoperator/templates/monitoring.yaml b/charts/redisoperator/templates/monitoring.yaml index 02213dbaf..8cf9e2492 100644 --- a/charts/redisoperator/templates/monitoring.yaml +++ b/charts/redisoperator/templates/monitoring.yaml @@ -6,6 +6,7 @@ apiVersion: v1 kind: Service metadata: name: {{ $fullName }}-prometheus + namespace: {{ include "chart.namespaceName" . }} labels: prometheus: {{ .Values.monitoring.prometheus.name }} {{- include "chart.labels" $data | nindent 4 }} @@ -28,6 +29,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ $fullName }} + namespace: {{ include "chart.namespaceName" . }} labels: prometheus: {{ .Values.monitoring.prometheus.name }} {{- include "chart.labels" $data | nindent 4 }} @@ -38,7 +40,7 @@ spec: {{- include "chart.selectorLabels" $data | nindent 6 }} namespaceSelector: matchNames: - - {{ .Release.Namespace }} + - {{ include "chart.namespaceName" . }} endpoints: - port: metrics interval: 15s diff --git a/charts/redisoperator/templates/private-registry.yaml b/charts/redisoperator/templates/private-registry.yaml index e267c99eb..0df3a1b1f 100644 --- a/charts/redisoperator/templates/private-registry.yaml +++ b/charts/redisoperator/templates/private-registry.yaml @@ -6,6 +6,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ $fullName }}-{{ $name }} + namespace: {{ include "chart.namespaceName" . }} labels: {{- include "chart.labels" $data | nindent 4 }} {{- if .Values.annotations }} diff --git a/charts/redisoperator/templates/service-account.yaml b/charts/redisoperator/templates/service-account.yaml index 940339d22..fc9805b88 100644 --- a/charts/redisoperator/templates/service-account.yaml +++ b/charts/redisoperator/templates/service-account.yaml @@ -5,6 +5,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ $fullName }} + namespace: {{ include "chart.namespaceName" . }} labels: {{- include "chart.labels" $data | nindent 4 }} --- @@ -106,7 +107,7 @@ metadata: subjects: - kind: ServiceAccount name: {{ $fullName }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "chart.namespaceName" . }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/charts/redisoperator/templates/service.yaml b/charts/redisoperator/templates/service.yaml index 5b7050e47..9291a266c 100644 --- a/charts/redisoperator/templates/service.yaml +++ b/charts/redisoperator/templates/service.yaml @@ -5,6 +5,7 @@ apiVersion: v1 kind: Service metadata: name: {{ $fullName }} + namespace: {{ include "chart.namespaceName" . }} labels: {{- include "chart.labels" $data | nindent 4 }} {{- if .Values.annotations }} diff --git a/charts/redisoperator/values.yaml b/charts/redisoperator/values.yaml index a8dd81abe..c469ac452 100644 --- a/charts/redisoperator/values.yaml +++ b/charts/redisoperator/values.yaml @@ -29,6 +29,10 @@ nameOverride: "" # A name to substitute for the full names of resources. fullnameOverride: "" +# The name of the Namespace to deploy +# If not set, `.Release.Namespace` is used +namespace: null + serviceAccount: # Enable service account creation. create: true