Skip to content

Commit b603ce3

Browse files
authored
Merge pull request #3911 from rstribrn/feature/#3910_namespace_override
charts: namespaceOverride added
2 parents a8f4cae + 92bd4d9 commit b603ce3

30 files changed

+390
-11
lines changed

charts/headlamp/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ config:
131131
| imagePullSecrets | list | `[]` | Image pull secrets references |
132132
| nameOverride | string | `""` | Override the name of the chart |
133133
| fullnameOverride | string | `""` | Override the full name of the chart |
134+
| namespaceOverride | string | `""` | Override the deployment namespace; defaults to .Release.Namespace |
134135
| initContainers | list | `[]` | Init containers to run before main container |
135136

136137
### Security Configuration

charts/headlamp/templates/NOTES.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
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 {{ include "headlamp.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 "headlamp.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "headlamp.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ include "headlamp.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.
14-
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "headlamp.fullname" . }}'
15-
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "headlamp.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
14+
You can watch the status of by running 'kubectl get --namespace {{ include "headlamp.namespace" . }} svc -w {{ include "headlamp.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "headlamp.namespace" . }} {{ include "headlamp.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
1616
echo http://$SERVICE_IP:{{ .Values.service.port }}
1717
{{- else if contains "ClusterIP" .Values.service.type }}
18-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "headlamp.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19-
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
18+
export POD_NAME=$(kubectl get pods --namespace {{ include "headlamp.namespace" . }} -l "app.kubernetes.io/name={{ include "headlamp.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ include "headlamp.namespace" . }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
2020
echo "Visit http://127.0.0.1:8080 to use your application"
21-
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
21+
kubectl --namespace {{ include "headlamp.namespace" . }} port-forward $POD_NAME 8080:$CONTAINER_PORT
2222
{{- end }}
2323
{{- if .Values.clusterRoleBinding.create }}
2424
{{- if and ( ge .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "24" ) }}
2525
2. Get the token using
26-
kubectl create token {{ include "headlamp.serviceAccountName" . }} --namespace {{.Release.Namespace}}
26+
kubectl create token {{ include "headlamp.serviceAccountName" . }} --namespace {{ include "headlamp.namespace" . }}
2727
{{- else }}
2828
2. Get the clusterrolebinding token using
29-
export SECRET=$(kubectl get secrets --namespace {{ .Release.Namespace }} -o custom-columns=":metadata.name" | grep "{{ include "headlamp.fullname" . }}-token")
30-
kubectl get secret $SECRET --namespace {{ .Release.Namespace }} --template=\{\{.data.token\}\} | base64 --decode
29+
export SECRET=$(kubectl get secrets --namespace {{ include "headlamp.namespace" . }} -o custom-columns=":metadata.name" | grep "{{ include "headlamp.fullname" . }}-token")
30+
kubectl get secret $SECRET --namespace {{ include "headlamp.namespace" . }} --template=\{\{.data.token\}\} | base64 --decode
3131
{{- end }}
3232
{{- end }}

charts/headlamp/templates/_helpers.tpl

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

26+
{{/*
27+
Expand the namespace of the release.
28+
Allows overriding it for multi-namespace deployments in combined charts.
29+
*/}}
30+
{{- define "headlamp.namespace" -}}
31+
{{- if .Values.namespaceOverride }}
32+
{{- .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
33+
{{- else if .Release.Namespace }}
34+
{{- .Release.Namespace | trunc 63 | trimSuffix "-" -}}
35+
{{- else -}}
36+
default
37+
{{- end -}}
38+
{{- end -}}
39+
2640
{{/*
2741
Create chart name and version as used by the chart label.
2842
*/}}

charts/headlamp/templates/clusterrolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ roleRef:
1616
subjects:
1717
- kind: ServiceAccount
1818
name: {{ include "headlamp.serviceAccountName" . }}
19-
namespace: {{ .Release.Namespace }}
19+
namespace: {{ include "headlamp.namespace" . }}
2020
{{- end }}

charts/headlamp/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ apiVersion: apps/v1
4343
kind: Deployment
4444
metadata:
4545
name: {{ include "headlamp.fullname" . }}
46+
namespace: {{ include "headlamp.namespace" . }}
4647
labels:
4748
{{- include "headlamp.labels" . | nindent 4 }}
4849
{{- with .Values.deploymentAnnotations }}

charts/headlamp/templates/ingress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ apiVersion: extensions/v1beta1
99
kind: Ingress
1010
metadata:
1111
name: {{ $fullName }}
12+
namespace: {{ include "headlamp.namespace" . }}
1213
labels:
1314
{{- include "headlamp.labels" . | nindent 4 }}
1415
{{- with .Values.ingress.labels }}

charts/headlamp/templates/pdb.yaml

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

charts/headlamp/templates/plugin-configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: v1
33
kind: ConfigMap
44
metadata:
55
name: {{ include "headlamp.fullname" . }}-plugin-config
6+
namespace: {{ include "headlamp.namespace" . }}
67
labels:
78
{{- include "headlamp.labels" . | nindent 4 }}
89
data:

charts/headlamp/templates/pvc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ apiVersion: v1
44
kind: PersistentVolumeClaim
55
metadata:
66
name: {{ $fullName }}
7+
namespace: {{ include "headlamp.namespace" . }}
78
labels:
89
{{- include "headlamp.labels" . | nindent 4 }}
910
{{- with .Values.persistentVolumeClaim.annotations }}

charts/headlamp/templates/secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ apiVersion: v1
44
kind: Secret
55
metadata:
66
name: {{ .secret.name }}
7+
namespace: {{ include "headlamp.namespace" $ }}
78
type: Opaque
89
data:
910
{{- with .clientID }}

0 commit comments

Comments
 (0)