Merge "helm-toolkit: Support standard kubernetes/helm labels"
This commit is contained in:
commit
ddb95379a4
@ -16,22 +16,45 @@ limitations under the License.
|
|||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
abstract: |
|
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: |
|
values: |
|
||||||
release_group: null
|
release_group: null
|
||||||
usage: |
|
usage: |
|
||||||
{{ tuple . "foo" "bar" | include "helm-toolkit.snippets.kubernetes_metadata_labels" }}
|
{{ tuple . "foo" "bar" | include "helm-toolkit.snippets.kubernetes_metadata_labels" }}
|
||||||
return: |
|
return: |
|
||||||
release_group: RELEASE-NAME
|
helm.sh/chart: "CHART-NAME-CHART-VERSION"
|
||||||
application: foo
|
app.kubernetes.io/managed-by: "Tiller"
|
||||||
component: bar
|
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" -}}
|
{{- define "helm-toolkit.snippets.kubernetes_metadata_labels" -}}
|
||||||
{{- $envAll := index . 0 -}}
|
{{- $envAll := index . 0 -}}
|
||||||
{{- $application := index . 1 -}}
|
{{- $chart := print $envAll.Chart.Name "-" $envAll.Chart.Version | replace "+" "_" | quote -}}
|
||||||
{{- $component := index . 2 -}}
|
{{- $_application := index . 1 -}}
|
||||||
release_group: {{ $envAll.Values.release_group | default $envAll.Release.Name }}
|
{{- $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 }}
|
application: {{ $application }}
|
||||||
component: {{ $component }}
|
component: {{ $component }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user