From d44e1c8f8a207b943d85fddebad6e335696fe760 Mon Sep 17 00:00:00 2001 From: Tanguy BAUDRIN Date: Thu, 12 Dec 2024 15:58:03 +0100 Subject: [PATCH] feat(deploy/helm): add value option to override release namespace --- .../kubernetes-replicator/templates/_helpers.tpl | 7 +++++++ .../kubernetes-replicator/templates/deployment.yaml | 1 + .../helm-chart/kubernetes-replicator/templates/rbac.yaml | 5 ++++- deploy/helm-chart/kubernetes-replicator/values.yaml | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/deploy/helm-chart/kubernetes-replicator/templates/_helpers.tpl b/deploy/helm-chart/kubernetes-replicator/templates/_helpers.tpl index b28760a2..6b385113 100644 --- a/deploy/helm-chart/kubernetes-replicator/templates/_helpers.tpl +++ b/deploy/helm-chart/kubernetes-replicator/templates/_helpers.tpl @@ -31,6 +31,13 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Create namespace used by the chart, defaulting to helm release namespace +*/}} +{{- define "kubernetes-replicator.namespace" -}} +{{- default .Release.Namespace .Values.namespaceOverride -}} +{{- end -}} + {{/* Common labels */}} diff --git a/deploy/helm-chart/kubernetes-replicator/templates/deployment.yaml b/deploy/helm-chart/kubernetes-replicator/templates/deployment.yaml index 218ff845..826cc2ea 100644 --- a/deploy/helm-chart/kubernetes-replicator/templates/deployment.yaml +++ b/deploy/helm-chart/kubernetes-replicator/templates/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "kubernetes-replicator.fullname" . }} + namespace: {{ include "kubernetes-replicator.namespace" . | quote }} labels: {{- include "kubernetes-replicator.labels" . | nindent 4 }} {{- if .Values.labels }} diff --git a/deploy/helm-chart/kubernetes-replicator/templates/rbac.yaml b/deploy/helm-chart/kubernetes-replicator/templates/rbac.yaml index 920b513b..26dba446 100644 --- a/deploy/helm-chart/kubernetes-replicator/templates/rbac.yaml +++ b/deploy/helm-chart/kubernetes-replicator/templates/rbac.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "kubernetes-replicator.serviceAccountName" . }} + namespace: {{ include "kubernetes-replicator.namespace" . | quote }} labels: {{- include "kubernetes-replicator.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} @@ -15,6 +16,7 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ include "kubernetes-replicator.fullname" . }} + namespace: {{ include "kubernetes-replicator.namespace" . | quote }} labels: {{- include "kubernetes-replicator.labels" . | nindent 4 }} rules: @@ -87,6 +89,7 @@ kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ include "kubernetes-replicator.fullname" . }} + namespace: {{ include "kubernetes-replicator.namespace" . | quote }} labels: {{- include "kubernetes-replicator.labels" . | nindent 4 }} roleRef: @@ -96,5 +99,5 @@ roleRef: subjects: - kind: ServiceAccount name: {{ include "kubernetes-replicator.serviceAccountName" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "kubernetes-replicator.namespace" . | quote }} {{- end -}} diff --git a/deploy/helm-chart/kubernetes-replicator/values.yaml b/deploy/helm-chart/kubernetes-replicator/values.yaml index 6555026d..d39cedf6 100644 --- a/deploy/helm-chart/kubernetes-replicator/values.yaml +++ b/deploy/helm-chart/kubernetes-replicator/values.yaml @@ -5,6 +5,7 @@ image: imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +namespaceOverride: "" grantClusterAdmin: false automountServiceAccountToken: true # args: