Make app.kubernetes.io labels optional

This set of labels is not mandatory and introduces additional
complexity in upgrading existing Helm charts as labels field
is immutable and corresponding resources has to be deleted
before upgrade. The default behavior won't be changed and labels
won't be added only if explicitly disabled via values.

Change-Id: I2bc1cdefdc2819100195502003d69fd8576554ab
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
This commit is contained in:
Ruslan Aliev 2025-04-01 16:54:11 -05:00
parent 6b985e51be
commit f37dd907f9

View File

@ -37,18 +37,22 @@ return: |
{{- $envAll := index . 0 -}} {{- $envAll := index . 0 -}}
{{- $application := index . 1 -}} {{- $application := index . 1 -}}
{{- $component := index . 2 -}} {{- $component := index . 2 -}}
{{- $podValues := $envAll.Values.pod | default dict -}}
{{- $labels := $podValues.labels | default dict -}}
release_group: {{ $envAll.Values.release_group | default $envAll.Release.Name }} release_group: {{ $envAll.Values.release_group | default $envAll.Release.Name }}
application: {{ $application }} application: {{ $application }}
component: {{ $component }} component: {{ $component }}
{{- if or $labels.include_app_kubernetes_io (not (hasKey $labels "include_app_kubernetes_io")) }}
app.kubernetes.io/name: {{ $application }} app.kubernetes.io/name: {{ $application }}
app.kubernetes.io/component: {{ $component }} app.kubernetes.io/component: {{ $component }}
app.kubernetes.io/instance: {{ $envAll.Values.release_group | default $envAll.Release.Name }} app.kubernetes.io/instance: {{ $envAll.Values.release_group | default $envAll.Release.Name }}
{{- if ($envAll.Values.pod).labels }}
{{- if hasKey $envAll.Values.pod.labels $component }}
{{ index $envAll.Values.pod "labels" $component | toYaml }}
{{- end -}} {{- end -}}
{{- if hasKey $envAll.Values.pod.labels "default" }} {{- if $labels }}
{{ $envAll.Values.pod.labels.default | toYaml }} {{- if hasKey $labels $component }}
{{ index $podValues "labels" $component | toYaml }}
{{- end -}}
{{- if hasKey $labels "default" }}
{{ $labels.default | toYaml }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}