From 6ab14548a262e0a4989cd97d087f34446627249b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Mart=C3=ADnez=20Vega?= Date: Fri, 29 May 2020 13:05:26 -0500 Subject: [PATCH] [kibana] Add extensible label support (#555) Common labels were moved to helpers template to have only one source of truth of common/added labels shared between all Kibana resources. Also, this extends the capability to add a custom label and this will be common between all the resources. --- kibana/templates/_helpers.tpl | 12 ++++++++++++ kibana/templates/configmap.yaml | 4 +--- kibana/templates/deployment.yaml | 7 +------ kibana/templates/ingress.yaml | 5 +---- kibana/templates/service.yaml | 5 +---- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/kibana/templates/_helpers.tpl b/kibana/templates/_helpers.tpl index 2fe259ebd..d2ab927b6 100755 --- a/kibana/templates/_helpers.tpl +++ b/kibana/templates/_helpers.tpl @@ -29,3 +29,15 @@ Return the appropriate apiVersion for ingress. {{- print "networking.k8s.io/v1beta1" -}} {{- end -}} {{- end -}} + +{{/* +Common labels +*/}} +{{- define "kibana.labels" -}} +app: {{ .Chart.Name }} +release: {{ .Release.Name | quote }} +heritage: {{ .Release.Service }} +{{- if .Values.labels }} +{{ toYaml .Values.labels }} +{{- end }} +{{- end -}} diff --git a/kibana/templates/configmap.yaml b/kibana/templates/configmap.yaml index 88927597a..2c9dc0fba 100644 --- a/kibana/templates/configmap.yaml +++ b/kibana/templates/configmap.yaml @@ -4,9 +4,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "kibana.fullname" . }}-config - labels: - app: {{ .Chart.Name }} - release: {{ .Release.Name | quote }} + labels: {{ include "kibana.labels" . | nindent 4 }} data: {{- range $path, $config := .Values.kibanaConfig }} {{ $path }}: | diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index 9d7109265..5555d2ad0 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -2,12 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "kibana.fullname" . }} - labels: - app: {{ .Chart.Name }} - release: {{ .Release.Name | quote }} - {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value | quote }} - {{- end }} + labels: {{ include "kibana.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas }} strategy: diff --git a/kibana/templates/ingress.yaml b/kibana/templates/ingress.yaml index e9aafcb65..e62977495 100644 --- a/kibana/templates/ingress.yaml +++ b/kibana/templates/ingress.yaml @@ -6,10 +6,7 @@ apiVersion: {{ template "kibana.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ $fullName }} - labels: - app: {{ .Chart.Name }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + labels: {{ include "kibana.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{ toYaml . | indent 4 }} diff --git a/kibana/templates/service.yaml b/kibana/templates/service.yaml index 5734580bf..71400a88d 100644 --- a/kibana/templates/service.yaml +++ b/kibana/templates/service.yaml @@ -3,10 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ template "kibana.fullname" . }} - labels: - app: {{ .Chart.Name }} - release: {{ .Release.Name | quote }} - heritage: {{ .Release.Service }} + labels: {{ include "kibana.labels" . | nindent 4 }} {{- if .Values.service.labels }} {{ toYaml .Values.service.labels | indent 4}} {{- end }}