Add lookup for existing label value

pull/1374/head
Brenda Rearden 2021-07-27 15:58:35 -07:00
parent 42258bb807
commit 76e6f9e49f
1 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,23 @@
--- charts-original/templates/_helpers.tpl
+++ charts/templates/_helpers.tpl
@@ -176,3 +176,11 @@
@@ -50,8 +50,15 @@
Selector labels
*/}}
{{- define "kiali-server.selectorLabels" -}}
+{{- $releaseName := .Release.Name -}}
+{{- $fullName := include "kiali-server.fullname" . -}}
+{{- $deployment := (lookup "apps/v1" "Deployment" .Release.Namespace $fullName) -}}
app.kubernetes.io/name: kiali
-app.kubernetes.io/instance: {{ include "kiali-server.fullname" . }}
+{{- if (and .Release.IsUpgrade $deployment)}}
+app.kubernetes.io/instance: {{ (get (($deployment).metadata.labels) "app.kubernetes.io/instance") | default $fullName }}
+{{- else }}
+app.kubernetes.io/instance: {{ $fullName }}
+{{- end }}
{{- end }}
{{/*
@@ -176,3 +183,11 @@
{{- end }}
{{- end }}
{{- end }}