From 53c86f22d300ab3874caad33cc09b60fe4c4a567 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 4 Nov 2021 16:07:27 +0100 Subject: [PATCH 1/2] Add: support custom labels Signed-off-by: Nicolas Lamirault --- .../aws-node-termination-handler/templates/_helpers.tpl | 7 ++++++- .../templates/clusterrole.yaml | 2 ++ .../templates/clusterrolebinding.yaml | 2 ++ .../templates/daemonset.linux.yaml | 2 +- .../templates/daemonset.windows.yaml | 2 +- .../aws-node-termination-handler/templates/deployment.yaml | 2 +- config/helm/aws-node-termination-handler/values.yaml | 4 ++++ 7 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config/helm/aws-node-termination-handler/templates/_helpers.tpl b/config/helm/aws-node-termination-handler/templates/_helpers.tpl index 249a9c98..f7a8324b 100644 --- a/config/helm/aws-node-termination-handler/templates/_helpers.tpl +++ b/config/helm/aws-node-termination-handler/templates/_helpers.tpl @@ -36,12 +36,17 @@ Name will not exceed 63 characters. Common labels */}} {{- define "aws-node-termination-handler.labels" -}} -helm.sh/chart: {{ include "aws-node-termination-handler.chart" . }} {{ include "aws-node-termination-handler.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} +app.kubernetes.io/component: {{ .Release.Name }} +app.kubernetes.io/part-of: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} +helm.sh/chart: {{ include "aws-node-termination-handler.chart" . }} +{{- if .Values.customLabels }} +{{ toYaml .Values.customLabels }} +{{- end }} {{- end -}} {{/* diff --git a/config/helm/aws-node-termination-handler/templates/clusterrole.yaml b/config/helm/aws-node-termination-handler/templates/clusterrole.yaml index 8418ff3e..42e1d874 100644 --- a/config/helm/aws-node-termination-handler/templates/clusterrole.yaml +++ b/config/helm/aws-node-termination-handler/templates/clusterrole.yaml @@ -2,6 +2,8 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ include "aws-node-termination-handler.fullname" . }} + labels: + {{- include "aws-node-termination-handler.labels" . | nindent 4 }} rules: - apiGroups: - "" diff --git a/config/helm/aws-node-termination-handler/templates/clusterrolebinding.yaml b/config/helm/aws-node-termination-handler/templates/clusterrolebinding.yaml index b5c25327..553c6678 100644 --- a/config/helm/aws-node-termination-handler/templates/clusterrolebinding.yaml +++ b/config/helm/aws-node-termination-handler/templates/clusterrolebinding.yaml @@ -2,6 +2,8 @@ kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ include "aws-node-termination-handler.fullname" . }} + labels: + {{- include "aws-node-termination-handler.labels" . | nindent 4 }} subjects: - kind: ServiceAccount name: {{ template "aws-node-termination-handler.serviceAccountName" . }} diff --git a/config/helm/aws-node-termination-handler/templates/daemonset.linux.yaml b/config/helm/aws-node-termination-handler/templates/daemonset.linux.yaml index 0a09aa64..c2d13e4c 100644 --- a/config/helm/aws-node-termination-handler/templates/daemonset.linux.yaml +++ b/config/helm/aws-node-termination-handler/templates/daemonset.linux.yaml @@ -29,7 +29,7 @@ spec: {{- end }} {{- end }} labels: - {{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }} + {{- include "aws-node-termination-handler.labels" . | nindent 8 }} k8s-app: aws-node-termination-handler {{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux {{- range $key, $value := (mergeOverwrite (dict) .Values.podLabels .Values.linuxPodLabels) }} diff --git a/config/helm/aws-node-termination-handler/templates/daemonset.windows.yaml b/config/helm/aws-node-termination-handler/templates/daemonset.windows.yaml index d5dfa6f8..f8521f4f 100644 --- a/config/helm/aws-node-termination-handler/templates/daemonset.windows.yaml +++ b/config/helm/aws-node-termination-handler/templates/daemonset.windows.yaml @@ -29,7 +29,7 @@ spec: {{- end }} {{- end }} labels: - {{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }} + {{- include "aws-node-termination-handler.labels" . | nindent 8 }} k8s-app: aws-node-termination-handler {{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: windows {{- range $key, $value := (mergeOverwrite (dict) .Values.podLabels .Values.windowsPodLabels) }} diff --git a/config/helm/aws-node-termination-handler/templates/deployment.yaml b/config/helm/aws-node-termination-handler/templates/deployment.yaml index d2e71157..e2abd154 100644 --- a/config/helm/aws-node-termination-handler/templates/deployment.yaml +++ b/config/helm/aws-node-termination-handler/templates/deployment.yaml @@ -19,7 +19,7 @@ spec: {{ $key }}: {{ $value | quote }} {{- end }} labels: - {{- include "aws-node-termination-handler.selectorLabels" . | nindent 8 }} + {{- include "aws-node-termination-handler.labels" . | nindent 8 }} k8s-app: aws-node-termination-handler {{ include "aws-node-termination-handler.nodeSelectorTermsOs" . }}: linux {{- range $key, $value := .Values.podLabels }} diff --git a/config/helm/aws-node-termination-handler/values.yaml b/config/helm/aws-node-termination-handler/values.yaml index 125e2700..ba66b982 100644 --- a/config/helm/aws-node-termination-handler/values.yaml +++ b/config/helm/aws-node-termination-handler/values.yaml @@ -8,6 +8,10 @@ image: pullPolicy: IfNotPresent pullSecrets: [] +# -- Custom labels to add into metadata +customLabels: #{} + app: aws-node-termination-handler + securityContext: runAsUserID: 1000 runAsGroupID: 1000 From 7624a192b7f8faa6bd5dbb8d6968356f6dd1eb1d Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 4 Nov 2021 16:09:25 +0100 Subject: [PATCH 2/2] Fix: do not add custom labels Signed-off-by: Nicolas Lamirault --- config/helm/aws-node-termination-handler/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/helm/aws-node-termination-handler/values.yaml b/config/helm/aws-node-termination-handler/values.yaml index ba66b982..f3a12c18 100644 --- a/config/helm/aws-node-termination-handler/values.yaml +++ b/config/helm/aws-node-termination-handler/values.yaml @@ -9,8 +9,8 @@ image: pullSecrets: [] # -- Custom labels to add into metadata -customLabels: #{} - app: aws-node-termination-handler +customLabels: {} + # app: aws-node-termination-handler securityContext: runAsUserID: 1000