Skip to content

Commit 69a5350

Browse files
NR4l3rt0elenz97
andauthored
feat(chart): allow namespace override in chart (#395)
This commit will allow to override the namespace metadata field of the provided Kubernetes objects by the Chart. It is taken into account the scope of those, meaning if they are namespaced or not. Signed-off-by: Alberto Ruiz <alberto.ruizm@outlook.com> Co-authored-by: Eike Lenz <e.lenz@mittwald.de>
1 parent 0447c4a commit 69a5350

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

deploy/helm-chart/kubernetes-replicator/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Create chart name and version as used by the chart label.
3131
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
3232
{{- end -}}
3333

34+
{{/*
35+
Create namespace name using the value of the release object or custom override.
36+
*/}}
37+
{{- define "kubernetes-replicator.namespace" -}}
38+
{{- default .Release.Namespace .Values.namespaceOverride -}}
39+
{{- end -}}
40+
3441
{{/*
3542
Common labels
3643
*/}}

deploy/helm-chart/kubernetes-replicator/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ include "kubernetes-replicator.fullname" . }}
5+
namespace: {{ include "kubernetes-replicator.namespace" . }}
56
labels:
67
{{- include "kubernetes-replicator.labels" . | nindent 4 }}
78
{{- if .Values.labels }}

deploy/helm-chart/kubernetes-replicator/templates/rbac.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: v1
33
kind: ServiceAccount
44
metadata:
55
name: {{ include "kubernetes-replicator.serviceAccountName" . }}
6+
namespace: {{ include "kubernetes-replicator.namespace" . }}
67
labels:
78
{{- include "kubernetes-replicator.labels" . | nindent 4 }}
89
{{- with .Values.serviceAccount.annotations }}
@@ -71,5 +72,5 @@ roleRef:
7172
subjects:
7273
- kind: ServiceAccount
7374
name: {{ include "kubernetes-replicator.serviceAccountName" . }}
74-
namespace: {{ .Release.Namespace | quote }}
75+
namespace: {{ include "kubernetes-replicator.namespace" . }}
7576
{{- end -}}

deploy/helm-chart/kubernetes-replicator/templates/verticalpodautoscaler.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: autoscaling.k8s.io/v1
33
kind: VerticalPodAutoscaler
44
metadata:
55
name: {{ include "kubernetes-replicator.fullname" . }}
6+
namespace: {{ include "kubernetes-replicator.namespace" . }}
67
labels:
78
{{- include "kubernetes-replicator.labels" . | nindent 4 }}
89
spec:

deploy/helm-chart/kubernetes-replicator/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ image:
55
imagePullSecrets: []
66
nameOverride: ""
77
fullnameOverride: ""
8+
namespaceOverride: ""
89
grantClusterAdmin: false
910
automountServiceAccountToken: true
1011
# args:

0 commit comments

Comments
 (0)