diff --git a/charts/nginx-ingress/templates/_helpers.tpl b/charts/nginx-ingress/templates/_helpers.tpl index e9a12d2197..4b65c23082 100644 --- a/charts/nginx-ingress/templates/_helpers.tpl +++ b/charts/nginx-ingress/templates/_helpers.tpl @@ -60,6 +60,21 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} +{{/* +Pod labels +*/}} +{{- define "nginx-ingress.podLabels" -}} +{{- include "nginx-ingress.selectorLabels" . }} +{{- if .Values.nginxServiceMesh.enable }} +nsm.nginx.com/enable-ingress: "true" +nsm.nginx.com/enable-egress: "{{ .Values.nginxServiceMesh.enableEgress }}" +nsm.nginx.com/{{ .Values.controller.kind }}: {{ include "nginx-ingress.controller.fullname" . }} +{{- end }} +{{- if .Values.controller.pod.extraLabels }} +{{ toYaml .Values.controller.pod.extraLabels }} +{{- end }} +{{- end }} + {{/* Selector labels */}} diff --git a/charts/nginx-ingress/templates/controller-daemonset.yaml b/charts/nginx-ingress/templates/controller-daemonset.yaml index 5cf53843b4..8da65c4683 100644 --- a/charts/nginx-ingress/templates/controller-daemonset.yaml +++ b/charts/nginx-ingress/templates/controller-daemonset.yaml @@ -16,15 +16,7 @@ spec: template: metadata: labels: - {{- include "nginx-ingress.selectorLabels" . | nindent 8 }} -{{- if .Values.nginxServiceMesh.enable }} - nsm.nginx.com/enable-ingress: "true" - nsm.nginx.com/enable-egress: "{{ .Values.nginxServiceMesh.enableEgress }}" - nsm.nginx.com/daemonset: {{ include "nginx-ingress.controller.fullname" . }} -{{- end }} -{{- if .Values.controller.pod.extraLabels }} -{{ toYaml .Values.controller.pod.extraLabels | indent 8 }} -{{- end }} + {{- include "nginx-ingress.podLabels" . | nindent 8 }} {{- if or .Values.prometheus.create .Values.controller.pod.annotations }} annotations: {{- if .Values.prometheus.create }} diff --git a/charts/nginx-ingress/templates/controller-deployment.yaml b/charts/nginx-ingress/templates/controller-deployment.yaml index 4db6246c7e..c8bc8f833c 100644 --- a/charts/nginx-ingress/templates/controller-deployment.yaml +++ b/charts/nginx-ingress/templates/controller-deployment.yaml @@ -19,15 +19,7 @@ spec: template: metadata: labels: - {{- include "nginx-ingress.selectorLabels" . | nindent 8 }} -{{- if .Values.nginxServiceMesh.enable }} - nsm.nginx.com/enable-ingress: "true" - nsm.nginx.com/enable-egress: "{{ .Values.nginxServiceMesh.enableEgress }}" - nsm.nginx.com/deployment: {{ include "nginx-ingress.controller.fullname" . }} -{{- end }} -{{- if .Values.controller.pod.extraLabels }} -{{ toYaml .Values.controller.pod.extraLabels | indent 8 }} -{{- end }} + {{- include "nginx-ingress.podLabels" . | nindent 8 }} {{- if or .Values.prometheus.create .Values.controller.pod.annotations }} annotations: {{- if .Values.prometheus.create }}