Use Env expansion for namespace in args
When deploying the controller to a custom namespace, users have to overwrite the namespace attribute as well as the hardcoded namespace values in a number of args for the Deployment and the admission controller Jobs. Instead, this commit, uses the namespace name from the DownwardAPI, and allows users to simply change the namespace attribute without having to worry about the container args.
This commit is contained in:
parent
3435e78cd7
commit
59b16c4e92
4 changed files with 19 additions and 9 deletions
|
@ -48,7 +48,7 @@ Users can provide an override for an explicit service they want bound via `.Valu
|
||||||
|
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "ingress-nginx.controller.publishServicePath" -}}
|
{{- define "ingress-nginx.controller.publishServicePath" -}}
|
||||||
{{- $defServiceName := printf "%s/%s" .Release.Namespace (include "ingress-nginx.controller.fullname" .) -}}
|
{{- $defServiceName := printf "%s/%s" "$(POD_NAMESPACE)" (include "ingress-nginx.controller.fullname" .) -}}
|
||||||
{{- $servicePath := default $defServiceName .Values.controller.publishService.pathOverride }}
|
{{- $servicePath := default $defServiceName .Values.controller.publishService.pathOverride }}
|
||||||
{{- print $servicePath | trimSuffix "-" -}}
|
{{- print $servicePath | trimSuffix "-" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -38,9 +38,14 @@ spec:
|
||||||
imagePullPolicy: {{ .Values.controller.admissionWebhooks.patch.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.controller.admissionWebhooks.patch.image.pullPolicy }}
|
||||||
args:
|
args:
|
||||||
- create
|
- create
|
||||||
- --host={{ include "ingress-nginx.controller.fullname" . }}-admission,{{ include "ingress-nginx.controller.fullname" . }}-admission.{{ .Release.Namespace }}.svc
|
- --host={{ include "ingress-nginx.controller.fullname" . }}-admission,{{ include "ingress-nginx.controller.fullname" . }}-admission.$(POD_NAMESPACE).svc
|
||||||
- --namespace={{ .Release.Namespace }}
|
- --namespace=$(POD_NAMESPACE)
|
||||||
- --secret-name={{ include "ingress-nginx.fullname" . }}-admission
|
- --secret-name={{ include "ingress-nginx.fullname" . }}-admission
|
||||||
|
env:
|
||||||
|
- name: POD_NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
restartPolicy: OnFailure
|
restartPolicy: OnFailure
|
||||||
serviceAccountName: {{ include "ingress-nginx.fullname" . }}-admission
|
serviceAccountName: {{ include "ingress-nginx.fullname" . }}-admission
|
||||||
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
||||||
|
|
|
@ -39,10 +39,15 @@ spec:
|
||||||
args:
|
args:
|
||||||
- patch
|
- patch
|
||||||
- --webhook-name={{ include "ingress-nginx.fullname" . }}-admission
|
- --webhook-name={{ include "ingress-nginx.fullname" . }}-admission
|
||||||
- --namespace={{ .Release.Namespace }}
|
- --namespace=$(POD_NAMESPACE)
|
||||||
- --patch-mutating=false
|
- --patch-mutating=false
|
||||||
- --secret-name={{ include "ingress-nginx.fullname" . }}-admission
|
- --secret-name={{ include "ingress-nginx.fullname" . }}-admission
|
||||||
- --patch-failure-policy={{ .Values.controller.admissionWebhooks.failurePolicy }}
|
- --patch-failure-policy={{ .Values.controller.admissionWebhooks.failurePolicy }}
|
||||||
|
env:
|
||||||
|
- name: POD_NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
restartPolicy: OnFailure
|
restartPolicy: OnFailure
|
||||||
serviceAccountName: {{ include "ingress-nginx.fullname" . }}-admission
|
serviceAccountName: {{ include "ingress-nginx.fullname" . }}-admission
|
||||||
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
||||||
|
|
|
@ -71,22 +71,22 @@ spec:
|
||||||
args:
|
args:
|
||||||
- /nginx-ingress-controller
|
- /nginx-ingress-controller
|
||||||
{{- if .Values.defaultBackend.enabled }}
|
{{- if .Values.defaultBackend.enabled }}
|
||||||
- --default-backend-service={{ .Release.Namespace }}/{{ include "ingress-nginx.defaultBackend.fullname" . }}
|
- --default-backend-service=$(POD_NAMESPACE)/{{ include "ingress-nginx.defaultBackend.fullname" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.controller.publishService.enabled }}
|
{{- if .Values.controller.publishService.enabled }}
|
||||||
- --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }}
|
- --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- --election-id={{ .Values.controller.electionID }}
|
- --election-id={{ .Values.controller.electionID }}
|
||||||
- --ingress-class={{ .Values.controller.ingressClass }}
|
- --ingress-class={{ .Values.controller.ingressClass }}
|
||||||
- --configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.controller.fullname" . }}
|
- --configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.controller.fullname" . }}
|
||||||
{{- if .Values.tcp }}
|
{{- if .Values.tcp }}
|
||||||
- --tcp-services-configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.fullname" . }}-tcp
|
- --tcp-services-configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.fullname" . }}-tcp
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.udp }}
|
{{- if .Values.udp }}
|
||||||
- --udp-services-configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.fullname" . }}-udp
|
- --udp-services-configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.fullname" . }}-udp
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.controller.scope.enabled }}
|
{{- if .Values.controller.scope.enabled }}
|
||||||
- --watch-namespace={{ default .Release.Namespace .Values.controller.scope.namespace }}
|
- --watch-namespace={{ default "$(POD_NAMESPACE)" .Values.controller.scope.namespace }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if and .Values.controller.reportNodeInternalIp .Values.controller.hostNetwork }}
|
{{- if and .Values.controller.reportNodeInternalIp .Values.controller.hostNetwork }}
|
||||||
- --report-node-internal-ip-address={{ .Values.controller.reportNodeInternalIp }}
|
- --report-node-internal-ip-address={{ .Values.controller.reportNodeInternalIp }}
|
||||||
|
|
Loading…
Reference in a new issue