Skip to content

Commit 16c1251

Browse files
feat: add namespace overrides (#471)
Allow to override the default namespace in an Umbrella chart Co-authored-by: Romeo Dumitrescu <[email protected]>
1 parent b8b4705 commit 16c1251

File tree

9 files changed

+20
-8
lines changed

9 files changed

+20
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ You can customize the values of the helm deployment by using the following Value
3535
| Parameter | Description | Default |
3636
| ---------------------------------------- | ------------------------------------------------ | ------------------------------------------------------- |
3737
| `nameOverride` | Overrides release name | `""` |
38+
| `namespaceOverride` | Overrides namespace | `""` |
3839
| `fullnameOverride` | Overrides release fullname | `""` |
3940
| `image.repository` | Container image repository | `emberstack/kubernetes-reflector` |
4041
| `image.tag` | Container image tag | `Same as chart version` |
@@ -165,6 +166,8 @@ spec:
165166
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: ""
166167
...
167168
```
169+
170+
=======
168171
> Since version 1.15 of cert-manager you can annotate `Ingress` to create secrets created from certificates for mirroring using `cert-manager.io/secret-template` annotation (see https://github.com/cert-manager/cert-manager/pull/6839).
169172
```yaml
170173
apiVersion: networking.k8s.io/v1

src/helm/reflector/templates/_helpers.tpl

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

33+
{{/*
34+
Expand the namespace of the release.
35+
Allows overriding it for multi-namespace deployments in combined charts.
36+
*/}}
37+
{{- define "reflector.namespace" -}}
38+
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
39+
{{- end -}}
40+
3341
{{/*
3442
Common labels
3543
*/}}

src/helm/reflector/templates/clusterRole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
55
name: {{ include "reflector.fullname" . }}
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "reflector.namespace" . }}
77
labels:
88
{{- include "reflector.labels" . | nindent 4 }}
99
rules:

src/helm/reflector/templates/clusterRoleBinding.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:
55
name: {{ include "reflector.fullname" . }}
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "reflector.namespace" . }}
77
labels:
88
{{- include "reflector.labels" . | nindent 4 }}
99
roleRef:
@@ -13,5 +13,5 @@ roleRef:
1313
subjects:
1414
- kind: ServiceAccount
1515
name: {{ include "reflector.serviceAccountName" . }}
16-
namespace: {{ .Release.Namespace }}
17-
{{- end }}
16+
namespace: {{ include "reflector.namespace" . }}
17+
{{- end }}

src/helm/reflector/templates/cron.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: {{ .Values.cron.apiVersion | default "batch/v1" }}
44
kind: CronJob
55
metadata:
66
name: {{ include "reflector.fullname" . }}
7-
namespace: {{ .Release.Namespace }}
7+
namespace: {{ include "reflector.namespace" . }}
88
labels:
99
{{- include "reflector.labels" . | nindent 4 }}
1010

src/helm/reflector/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apps/v1
44
kind: Deployment
55
metadata:
66
name: {{ include "reflector.fullname" . }}
7-
namespace: {{ .Release.Namespace }}
7+
namespace: {{ include "reflector.namespace" . }}
88
labels:
99
{{- include "reflector.labels" . | nindent 4 }}
1010

src/helm/reflector/templates/hpa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: autoscaling/v2
33
kind: HorizontalPodAutoscaler
44
metadata:
55
name: {{ include "reflector.fullname" . }}
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "reflector.namespace" . }}
77
labels:
88
{{- include "reflector.labels" . | nindent 4 }}
99
spec:

src/helm/reflector/templates/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v1
33
kind: ServiceAccount
44
metadata:
55
name: {{ include "reflector.serviceAccountName" . }}
6-
namespace: {{ .Release.Namespace }}
6+
namespace: {{ include "reflector.namespace" . }}
77
labels:
88
{{- include "reflector.labels" . | nindent 4 }}
99
{{- with .Values.serviceAccount.annotations }}

src/helm/reflector/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ image:
1212

1313
imagePullSecrets: []
1414
nameOverride: ""
15+
namespaceOverride: ""
1516
fullnameOverride: ""
1617

1718
cron:

0 commit comments

Comments
 (0)