Skip to content

Commit

Permalink
fix: add .Release.Namespace in metadata (#152)
Browse files Browse the repository at this point in the history
Adding .Release.Namespace in metadata fixes issues when rendering template with 'helm template --namespace'. Without it, the rendered templates do not have the namespace defined which is problematic when using a gitops approach.

Signed-off-by: Jérémy Bertozzi <[email protected]>
Co-authored-by: Jérémy Bertozzi <[email protected]>
  • Loading branch information
jbertozzi and Jérémy Bertozzi authored Nov 29, 2023
1 parent e1ab4b3 commit ee8cc5b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions charts/coredns/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: coredns
version: 1.28.1
version: 1.28.2
appVersion: 1.11.1
home: https://coredns.io
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
Expand All @@ -20,5 +20,5 @@ engine: gotpl
type: application
annotations:
artifacthub.io/changes: |
- kind: added
description: Added option to override defaultMode for extraSecrets
- kind: fixed
description: add .Release.Namespace in metadata
1 change: 1 addition & 0 deletions charts/coredns/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "coredns.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ default (include "coredns.fullname" .) .Values.deployment.name }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- if .Values.customLabels }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "coredns.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ template "coredns.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/service-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "coredns.fullname" . }}-metrics
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
app.kubernetes.io/component: metrics
{{- if .Values.customLabels }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ default (include "coredns.fullname" .) .Values.service.name }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "coredns.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if or .Values.serviceAccount.annotations .Values.customAnnotations }}
annotations:
Expand Down

0 comments on commit ee8cc5b

Please sign in to comment.