From f3e44efe099314326b10cf3eb84bc410e603e1f3 Mon Sep 17 00:00:00 2001 From: Marcos Estevez Date: Fri, 11 Oct 2019 09:47:53 +0200 Subject: [PATCH] Labels refactor --- helm/templates/_helpers.tpl | 5 +---- helm/templates/clusterrole.yaml | 1 - helm/templates/clusterrolebinding.yaml | 1 - helm/templates/configmap.yaml | 2 ++ helm/templates/deployment.yaml | 7 +++---- helm/templates/serviceaccount.yaml | 1 - 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 712d6fda..8c864a24 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -15,12 +15,9 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{- define "wave-labels.selector" -}} +{{- define "wave-labels.chart" -}} app: {{ template "wave-name" . }} release: {{ .Release.Name | quote }} -{{- end -}} - -{{- define "wave-labels.chart" -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" heritage: {{ .Release.Service | quote }} {{- end -}} diff --git a/helm/templates/clusterrole.yaml b/helm/templates/clusterrole.yaml index 9fa8d561..547f23fd 100644 --- a/helm/templates/clusterrole.yaml +++ b/helm/templates/clusterrole.yaml @@ -4,7 +4,6 @@ kind: ClusterRole metadata: labels: {{ include "wave-labels.chart" . | indent 4 }} -{{ include "wave-labels.selector" . | indent 4 }} name: {{ template "wave-fullname" . }} rules: - apiGroups: diff --git a/helm/templates/clusterrolebinding.yaml b/helm/templates/clusterrolebinding.yaml index 8a846675..1d5ee362 100644 --- a/helm/templates/clusterrolebinding.yaml +++ b/helm/templates/clusterrolebinding.yaml @@ -4,7 +4,6 @@ kind: ClusterRoleBinding metadata: labels: {{ include "wave-labels.chart" . | indent 4 }} -{{ include "wave-labels.selector" . | indent 4 }} name: {{ template "wave-fullname" . }} roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index e906e205..bd6493db 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -2,6 +2,8 @@ apiVersion: v1 kind: ConfigMap metadata: + labels: +{{ include "wave-labels.chart" . | indent 4 }} name: {{ template "wave-fullname" . }} data: {{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 46a2fca0..813e8053 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -4,22 +4,21 @@ metadata: annotations: {{ toYaml .Values.annotations | nindent 4 }} labels: {{ include "wave-labels.chart" . | indent 4 }} -{{ include "wave-labels.selector" . | indent 4 }} name: {{ template "wave-fullname" . }} spec: replicas: {{ .Values.replicas }} selector: - matchLabels: {{ include "wave-labels.selector" . | nindent 6 }} + matchLabels: +{{ include "wave-labels.chart" . | indent 6 }} template: metadata: labels: -{{ include "wave-labels.selector" . | indent 8 }} {{ include "wave-labels.chart" . | indent 8 }} spec: containers: - image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - name: {{ template "wave-name" . }} + name: {{ template "wave-fullname" . }} args: {{- if gt .Values.replicas 1.0 }} - --leader-election=true diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml index eddb1b7c..a5ba1ef8 100644 --- a/helm/templates/serviceaccount.yaml +++ b/helm/templates/serviceaccount.yaml @@ -7,6 +7,5 @@ imagePullSecrets: {{ toYaml .Values.global.imagePullSecrets | nindent 2 }} metadata: labels: {{ include "wave-labels.chart" . | indent 4 }} -{{ include "wave-labels.selector" . | indent 4 }} name: {{ .Values.serviceAccount.name | default (include "wave-fullname" .) }} {{- end }}