Skip to content

Commit 322b71c

Browse files
committed
feat(helm): Add namespace field to all resources
Signed-off-by: Marco Maurer <mkilchhofer@users.noreply.github.com>
1 parent b3396ad commit 322b71c

File tree

17 files changed

+33
-12
lines changed

17 files changed

+33
-12
lines changed

charts/podinfo/templates/NOTES.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
{{- end }}
77
{{- end }}
88
{{- else if contains "NodePort" .Values.service.type }}
9-
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "podinfo.fullname" . }})
10-
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
9+
export NODE_PORT=$(kubectl get --namespace {{ include "podinfo.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "podinfo.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ include "podinfo.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
1111
echo http://$NODE_IP:$NODE_PORT
1212
{{- else if contains "LoadBalancer" .Values.service.type }}
1313
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
1414
You can watch the status of by running 'kubectl get svc -w {{ template "podinfo.fullname" . }}'
15-
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "podinfo.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "podinfo.namespace" . }} {{ template "podinfo.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
1616
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
1717
{{- else if contains "ClusterIP" .Values.service.type }}
1818
echo "Visit http://127.0.0.1:8080 to use your application"
19-
kubectl -n {{ .Release.Namespace }} port-forward deploy/{{ template "podinfo.fullname" . }} 8080:{{ .Values.service.externalPort }}
19+
kubectl -n {{ include "podinfo.namespace" . }} port-forward deploy/{{ template "podinfo.fullname" . }} 8080:{{ .Values.service.externalPort }}
2020
{{- end }}

charts/podinfo/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ If release name contains chart name it will be used as a full name.
2323
{{- end }}
2424
{{- end }}
2525

26+
{{/*
27+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
28+
*/}}
29+
{{- define "podinfo.namespace" -}}
30+
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
31+
{{- end -}}
32+
2633
{{/*
2734
Create chart name and version as used by the chart label.
2835
*/}}

charts/podinfo/templates/certificate.yaml

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

charts/podinfo/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: {{ template "podinfo.fullname" . }}
5+
namespace: {{ include "podinfo.namespace" . }}
56
labels:
67
{{- include "podinfo.labels" . | nindent 4 }}
78
spec:

charts/podinfo/templates/hpa.yaml

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

charts/podinfo/templates/ingress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ apiVersion: networking.k8s.io/v1
55
kind: Ingress
66
metadata:
77
name: {{ $fullName }}
8+
namespace: {{ include "podinfo.namespace" . }}
89
labels:
910
{{- include "podinfo.labels" . | nindent 4 }}
1011
{{- with .Values.ingress.additionalLabels }}

charts/podinfo/templates/linkerd.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
apiVersion: linkerd.io/v1alpha2
33
kind: ServiceProfile
44
metadata:
5-
name: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
5+
name: {{ template "podinfo.fullname" . }}.{{ include "podinfo.namespace" . }}.svc.cluster.local
6+
namespace: {{ include "podinfo.namespace" . }}
67
labels:
78
{{- include "podinfo.labels" . | nindent 4 }}
89
spec:

charts/podinfo/templates/pdb.yaml

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

charts/podinfo/templates/service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: v1
33
kind: Service
44
metadata:
55
name: {{ template "podinfo.fullname" . }}
6+
namespace: {{ include "podinfo.namespace" . }}
67
labels:
78
{{- include "podinfo.labels" . | nindent 4 }}
89
{{- with .Values.service.annotations }}

charts/podinfo/templates/servicemonitor.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
55
name: {{ template "podinfo.fullname" . }}
6+
namespace: {{ include "podinfo.namespace" . }}
67
labels:
78
{{- include "podinfo.labels" . | nindent 4 }}
89
{{- with .Values.serviceMonitor.additionalLabels }}
@@ -15,7 +16,7 @@ spec:
1516
interval: {{ .Values.serviceMonitor.interval }}
1617
namespaceSelector:
1718
matchNames:
18-
- {{ .Release.Namespace }}
19+
- {{ include "podinfo.namespace" . }}
1920
selector:
2021
matchLabels:
2122
{{- include "podinfo.selectorLabels" . | nindent 6 }}

0 commit comments

Comments
 (0)