Merge "helm-toolkit: Support standard kubernetes/helm labels"
This commit is contained in:
commit
ddb95379a4
@ -16,22 +16,45 @@ limitations under the License.
|
||||
|
||||
{{/*
|
||||
abstract: |
|
||||
Renders a set of standardised labels
|
||||
Renders a set of standardised labels as per:
|
||||
https://docs.helm.sh/chart_best_practices/#standard-labels
|
||||
values: |
|
||||
release_group: null
|
||||
usage: |
|
||||
{{ tuple . "foo" "bar" | include "helm-toolkit.snippets.kubernetes_metadata_labels" }}
|
||||
return: |
|
||||
release_group: RELEASE-NAME
|
||||
application: foo
|
||||
component: bar
|
||||
helm.sh/chart: "CHART-NAME-CHART-VERSION"
|
||||
app.kubernetes.io/managed-by: "Tiller"
|
||||
app.kubernetes.io/instance: "RELEASE-NAME"
|
||||
app.kubernetes.io/version: "APP-VERSION"
|
||||
app.kubernetes.io/name: "foo"
|
||||
app.kubernetes.io/component: "bar"
|
||||
release_group: "RELEASE-NAME"
|
||||
application: "foo"
|
||||
component: "bar"
|
||||
*/}}
|
||||
|
||||
{{/* TODO: Remove old deprecated labels after an appropriate migration period */}}
|
||||
{{- define "helm-toolkit.snippets.kubernetes_metadata_labels" -}}
|
||||
{{- $envAll := index . 0 -}}
|
||||
{{- $application := index . 1 -}}
|
||||
{{- $component := index . 2 -}}
|
||||
release_group: {{ $envAll.Values.release_group | default $envAll.Release.Name }}
|
||||
{{- $chart := print $envAll.Chart.Name "-" $envAll.Chart.Version | replace "+" "_" | quote -}}
|
||||
{{- $_application := index . 1 -}}
|
||||
{{- $partOf := $envAll.Values.part_of | default $_application | quote -}}
|
||||
{{- $application := $_application | quote -}}
|
||||
{{- $component := index . 2 | quote -}}
|
||||
{{- $instance := $envAll.Values.release_group | default $envAll.Release.Name | quote -}}
|
||||
{{- $version := $envAll.Chart.AppVersion -}}
|
||||
{{- $managedBy := $envAll.Release.Service | quote -}}
|
||||
helm.sh/chart: {{ $chart }}
|
||||
app.kubernetes.io/managed-by: {{ $managedBy }}
|
||||
app.kubernetes.io/instance: {{ $instance }}
|
||||
{{- if $version }}
|
||||
app.kubernetes.io/version: {{ $version }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/name: {{ $application }}
|
||||
app.kubernetes.io/component: {{ $component }}
|
||||
app.kubernetes.io/part-of: {{ $partOf }}
|
||||
release_group: {{ $instance }}
|
||||
application: {{ $application }}
|
||||
component: {{ $component }}
|
||||
{{- end -}}
|
||||
|
Loading…
Reference in New Issue
Block a user