From af7eab0325c25df5e18cb041716f1d2f71fd6026 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 8 Aug 2018 12:21:38 -0400 Subject: [PATCH 1/4] Updating to the k8s label convention Closes #4335 Signed-off-by: Matt Farina --- .../alpine/templates/alpine-pod.yaml | 6 +-- .../novals/templates/alpine-pod.yaml | 8 ++-- .../signtest/alpine/templates/alpine-pod.yaml | 2 +- docs/chart_best_practices/labels.md | 15 +++++--- docs/chart_best_practices/pods.md | 4 +- docs/chart_template_guide/variables.md | 8 ++-- docs/charts.md | 12 +++--- docs/charts_hooks.md | 12 +++--- .../examples/alpine/templates/alpine-pod.yaml | 12 +++--- docs/examples/nginx/templates/configmap.yaml | 8 ++-- docs/examples/nginx/templates/deployment.yaml | 16 ++++---- .../nginx/templates/post-install-job.yaml | 16 ++++---- .../nginx/templates/pre-install-secret.yaml | 8 ++-- .../nginx/templates/service-test.yaml | 8 ++-- docs/examples/nginx/templates/service.yaml | 12 +++--- pkg/chartutil/create.go | 37 +++++++++++++++++-- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../charts/alpine/templates/alpine-pod.yaml | 2 +- .../signtest/alpine/templates/alpine-pod.yaml | 2 +- .../testdata/albatross/templates/svc.yaml | 6 +-- 25 files changed, 121 insertions(+), 85 deletions(-) diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml index ee61f2056..001c2cbbd 100644 --- a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml @@ -6,12 +6,12 @@ metadata: # The "heritage" label is used to track which tool deployed a given chart. # It is useful for admins who want to see what releases a particular tool # is responsible for. - heritage: {{.Release.Service | quote }} + app.kubernetes.io/managed-by: {{.Release.Service | quote }} # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{.Release.Name | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} # This makes it easy to audit chart usage. - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} spec: # This shows how to use a simple value. This will look for a passed-in value diff --git a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml index 3c77e97b5..f569d556c 100644 --- a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml @@ -6,12 +6,14 @@ metadata: # The "heritage" label is used to track which tool deployed a given chart. # It is useful for admins who want to see what releases a particular tool # is responsible for. - heritage: {{.Release.Service | quote }} + app.kubernetes.io/managed-by: {{.Release.Service | quote }} # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{.Release.Name | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} # This makes it easy to audit chart usage. - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" + annotations: + "helm.sh/created": {{.Release.Time.Seconds | quote }} spec: # This shows how to use a simple value. This will look for a passed-in value # called restartPolicy. If it is not found, it will use the default value. diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/docs/chart_best_practices/labels.md b/docs/chart_best_practices/labels.md index 1dbe27476..226d7fb1c 100644 --- a/docs/chart_best_practices/labels.md +++ b/docs/chart_best_practices/labels.md @@ -10,7 +10,7 @@ An item of metadata should be a label under the following conditions: - It is used by Kubernetes to identify this resource - It is useful to expose to operators for the purpose of querying the system. -For example, we suggest using `chart: NAME-VERSION` as a label so that operators +For example, we suggest using `helm.sh/chart: NAME-VERSION` as a label so that operators can conveniently find all of the instances of a particular chart to use. If an item of metadata is not used for querying, it should be set as an annotation @@ -25,7 +25,12 @@ are recommended, and _should_ be placed onto a chart for global consistency. Tho Name|Status|Description -----|------|---------- -release | REC | This should be the `{{ .Release.Name }}`. -chart | REC | This should be the chart name and version: `{{ .Chart.Name }}-{{ .Chart.Version \| replace "+" "_" }}`. -app | REC | This should be the app name, reflecting the entire app. Usually `{{ template "name" . }}` is used for this. This is used by many Kubernetes manifests, and is not Helm-specific. -component | OPT | This is a common label for marking the different roles that pieces may play in an application. For example, `component: frontend`. +`app.kubernetes.io/name` | REC | This should be the app name, reflecting the entire app. Usually `{{ template "name" . }}` is used for this. This is used by many Kubernetes manifests, and is not Helm-specific. +`helm.sh/chart` | REC | This should be the chart name and version: `{{ .Chart.Name }}-{{ .Chart.Version \| replace "+" "_" }}`. +`app.kubernetes.io/managed-by` | REC | This should always be set to `{{ .Release.Service }}`. It is for finding all things managed by Tiller. +`app.kubernetes.io/instance` | REC | This should be the `{{ .Release.Name }}`. It aid in differentiating between different instances of the same application. +`app.kubernetes.io/version` | OPT | The version of the app and can be set to `{{ .Chart.AppVersion }}`. +`app.kubernetes.io/component` | OPT | This is a common label for marking the different roles that pieces may play in an application. For example, `app.kubernetes.io/component: frontend`. +`app.kubernetes.io/part-of` | OPT | When multiple charts or pieces of software are used together to make one application. For example, application software and a database to produce a website. This can be set to the top level application being supported. + +You can find more information on the Kubernetes labels, prefixed with `app.kubernetes.io`, in the [Kubernetes documentation](https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/). diff --git a/docs/chart_best_practices/pods.md b/docs/chart_best_practices/pods.md index 3f26b0253..bc9b42dd9 100644 --- a/docs/chart_best_practices/pods.md +++ b/docs/chart_best_practices/pods.md @@ -52,11 +52,11 @@ All PodTemplate sections should specify a selector. For example: ```yaml selector: matchLabels: - app: MyName + app.kubernetes.io/name: MyName template: metadata: labels: - app: MyName + app.kubernetes.io/name: MyName ``` This is a good practice because it makes the relationship between the set and diff --git a/docs/chart_template_guide/variables.md b/docs/chart_template_guide/variables.md index b55e6e422..d924fe2cf 100644 --- a/docs/chart_template_guide/variables.md +++ b/docs/chart_template_guide/variables.md @@ -113,11 +113,11 @@ metadata: labels: # Many helm templates would use `.` below, but that will not work, # however `$` will work here - app: {{ template "fullname" $ }} + app.kubernetes.io/name: {{ template "fullname" $ }} # I cannot reference .Chart.Name, but I can do $.Chart.Name - chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" - release: "{{ $.Release.Name }}" - heritage: "{{ $.Release.Service }}" + helm.sh/chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" + app.kubernetes.io/instance: "{{ $.Release.Name }}" + app.kubernetes.io/managed-by: "{{ $.Release.Service }}" type: kubernetes.io/tls data: tls.crt: {{ .certificate }} diff --git a/docs/charts.md b/docs/charts.md index 442269e55..339c16bd7 100644 --- a/docs/charts.md +++ b/docs/charts.md @@ -523,15 +523,15 @@ metadata: name: deis-database namespace: deis labels: - heritage: deis + app.kubernetes.io/managed-by: deis spec: replicas: 1 selector: - app: deis-database + app.kubernetes.io/name: deis-database template: metadata: labels: - app: deis-database + app.kubernetes.io/name: deis-database spec: serviceAccount: deis-database containers: @@ -653,15 +653,15 @@ metadata: name: deis-database namespace: deis labels: - heritage: deis + app.kubernetes.io/managed-by: deis spec: replicas: 1 selector: - app: deis-database + app.kubernetes.io/name: deis-database template: metadata: labels: - app: deis-database + app.kubernetes.io/name: deis-database spec: serviceAccount: deis-database containers: diff --git a/docs/charts_hooks.md b/docs/charts_hooks.md index 347972209..042adc456 100644 --- a/docs/charts_hooks.md +++ b/docs/charts_hooks.md @@ -114,9 +114,9 @@ kind: Job metadata: name: "{{.Release.Name}}" labels: - heritage: {{.Release.Service | quote }} - release: {{.Release.Name | quote }} - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. @@ -128,9 +128,9 @@ spec: metadata: name: "{{.Release.Name}}" labels: - heritage: {{.Release.Service | quote }} - release: {{.Release.Name | quote }} - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" spec: restartPolicy: Never containers: diff --git a/docs/examples/alpine/templates/alpine-pod.yaml b/docs/examples/alpine/templates/alpine-pod.yaml index da9caef78..beafd7668 100644 --- a/docs/examples/alpine/templates/alpine-pod.yaml +++ b/docs/examples/alpine/templates/alpine-pod.yaml @@ -3,16 +3,16 @@ kind: Pod metadata: name: {{ template "alpine.fullname" . }} labels: - # The "heritage" label is used to track which tool deployed a given chart. + # The "app.kubernetes.io/managed-by" label is used to track which tool deployed a given chart. # It is useful for admins who want to see what releases a particular tool # is responsible for. - heritage: {{ .Release.Service }} - # The "release" convention makes it easy to tie a release to all of the + app.kubernetes.io/managed-by: {{ .Release.Service }} + # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{ .Release.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} # This makes it easy to audit chart usage. - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "alpine.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "alpine.name" . }} spec: # This shows how to use a simple value. This will look for a passed-in value called restartPolicy. restartPolicy: {{ .Values.restartPolicy }} diff --git a/docs/examples/nginx/templates/configmap.yaml b/docs/examples/nginx/templates/configmap.yaml index b90d6c0c7..0141cbc69 100644 --- a/docs/examples/nginx/templates/configmap.yaml +++ b/docs/examples/nginx/templates/configmap.yaml @@ -4,10 +4,10 @@ kind: ConfigMap metadata: name: {{ template "nginx.fullname" . }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "nginx.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "nginx.name" . }} data: # When the config map is mounted as a volume, these will be created as files. index.html: {{ .Values.index | quote }} diff --git a/docs/examples/nginx/templates/deployment.yaml b/docs/examples/nginx/templates/deployment.yaml index 5fa2633ea..08850935a 100644 --- a/docs/examples/nginx/templates/deployment.yaml +++ b/docs/examples/nginx/templates/deployment.yaml @@ -6,16 +6,16 @@ metadata: # multiple times into the same namespace. name: {{ template "nginx.fullname" . }} labels: - # The "heritage" label is used to track which tool deployed a given chart. + # The "app.kubernetes.io/managed-by" label is used to track which tool deployed a given chart. # It is useful for admins who want to see what releases a particular tool # is responsible for. - heritage: {{ .Release.Service }} - # The "release" convention makes it easy to tie a release to all of the + app.kubernetes.io/managed-by: {{ .Release.Service }} + # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{ .Release.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} # This makes it easy to audit chart usage. - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "nginx.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "nginx.name" . }} spec: replicas: {{ .Values.replicaCount }} template: @@ -26,8 +26,8 @@ spec: {{ toYaml .Values.podAnnotations | indent 8 }} {{- end }} labels: - app: {{ template "nginx.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "nginx.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} spec: containers: - name: {{ template "nginx.name" . }} diff --git a/docs/examples/nginx/templates/post-install-job.yaml b/docs/examples/nginx/templates/post-install-job.yaml index 9ec90cd0a..6e32086ab 100644 --- a/docs/examples/nginx/templates/post-install-job.yaml +++ b/docs/examples/nginx/templates/post-install-job.yaml @@ -3,16 +3,16 @@ kind: Job metadata: name: {{ template "nginx.fullname" . }} labels: - # The "heritage" label is used to track which tool deployed a given chart. + # The "app.kubernetes.io/managed-by" label is used to track which tool deployed a given chart. # It is useful for admins who want to see what releases a particular tool # is responsible for. - heritage: {{ .Release.Service }} - # The "release" convention makes it easy to tie a release to all of the + app.kubernetes.io/managed-by: {{ .Release.Service }} + # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{ .Release.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} # This makes it easy to audit chart usage. - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "nginx.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "nginx.name" . }} annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. @@ -22,8 +22,8 @@ spec: metadata: name: {{ template "nginx.fullname" . }} labels: - release: {{ .Release.Name }} - app: {{ template "nginx.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "nginx.name" . }} spec: # This shows how to use a simple value. This will look for a passed-in value # called restartPolicy. If it is not found, it will use the default value. diff --git a/docs/examples/nginx/templates/pre-install-secret.yaml b/docs/examples/nginx/templates/pre-install-secret.yaml index 6392f9684..07a9504b5 100644 --- a/docs/examples/nginx/templates/pre-install-secret.yaml +++ b/docs/examples/nginx/templates/pre-install-secret.yaml @@ -5,10 +5,10 @@ kind: Secret metadata: name: {{ template "nginx.fullname" . }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "nginx.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "nginx.name" . }} # This declares the resource to be a hook. By convention, we also name the # file "pre-install-XXX.yaml", but Helm itself doesn't care about file names. annotations: diff --git a/docs/examples/nginx/templates/service-test.yaml b/docs/examples/nginx/templates/service-test.yaml index 3913ead9c..ffb37e9f4 100644 --- a/docs/examples/nginx/templates/service-test.yaml +++ b/docs/examples/nginx/templates/service-test.yaml @@ -3,10 +3,10 @@ kind: Pod metadata: name: "{{ template "nginx.fullname" . }}-service-test" labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "nginx.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "nginx.name" . }} annotations: "helm.sh/hook": test-success spec: diff --git a/docs/examples/nginx/templates/service.yaml b/docs/examples/nginx/templates/service.yaml index 1481e34f0..03f7aa2c6 100644 --- a/docs/examples/nginx/templates/service.yaml +++ b/docs/examples/nginx/templates/service.yaml @@ -6,10 +6,10 @@ metadata: {{ toYaml .Values.service.annotations | indent 4 }} {{- end }} labels: - app: {{ template "nginx.name" . }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "nginx.name" . }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} name: {{ template "nginx.fullname" . }} spec: # Provides options for the service so chart users have the full choice @@ -35,5 +35,5 @@ spec: nodePort: {{ .Values.service.nodePort }} {{- end }} selector: - app: {{ template "nginx.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "nginx.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 8bf0fbf73..962a542e5 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -156,10 +156,10 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - app: {{ template ".name" . }} - chart: {{ template ".chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include ".name" . }} + helm.sh/chart: {{ include ".chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} {{- with .Values.ingress.annotations }} annotations: {{ toYaml . | indent 4 }} @@ -193,14 +193,22 @@ kind: Deployment metadata: name: {{ template ".fullname" . }} labels: +<<<<<<< HEAD app: {{ template ".name" . }} chart: {{ template ".chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} +======= + app.kubernetes.io/name: {{ include ".name" . }} + helm.sh/chart: {{ include ".chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +>>>>>>> e328d00a... Updating to the k8s label convention spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: +<<<<<<< HEAD app: {{ template ".name" . }} release: {{ .Release.Name }} template: @@ -208,6 +216,15 @@ spec: labels: app: {{ template ".name" . }} release: {{ .Release.Name }} +======= + app.kubernetes.io/name: {{ include ".name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include ".name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +>>>>>>> e328d00a... Updating to the k8s label convention spec: containers: - name: {{ .Chart.Name }} @@ -246,10 +263,17 @@ kind: Service metadata: name: {{ template ".fullname" . }} labels: +<<<<<<< HEAD app: {{ template ".name" . }} chart: {{ template ".chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} +======= + app.kubernetes.io/name: {{ include ".name" . }} + helm.sh/chart: {{ include ".chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +>>>>>>> e328d00a... Updating to the k8s label convention spec: type: {{ .Values.service.type }} ports: @@ -258,8 +282,13 @@ spec: protocol: TCP name: http selector: +<<<<<<< HEAD app: {{ template ".name" . }} release: {{ .Release.Name }} +======= + app.kubernetes.io/name: {{ include ".name" . }} + app.kubernetes.io/instancelease: {{ .Release.Name }} +>>>>>>> e328d00a... Updating to the k8s label convention ` const defaultNotes = `1. Get the application URL by running these commands: diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml b/pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100755 --- a/pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/downloader/testdata/signtest/alpine/templates/alpine-pod.yaml b/pkg/downloader/testdata/signtest/alpine/templates/alpine-pod.yaml index 0c6980cf7..5bbae10af 100644 --- a/pkg/downloader/testdata/signtest/alpine/templates/alpine-pod.yaml +++ b/pkg/downloader/testdata/signtest/alpine/templates/alpine-pod.yaml @@ -3,7 +3,7 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} + app.kubernetes.io/managed-by: {{.Release.Service}} chartName: {{.Chart.Name}} chartVersion: {{.Chart.Version | quote}} spec: diff --git a/pkg/lint/rules/testdata/albatross/templates/svc.yaml b/pkg/lint/rules/testdata/albatross/templates/svc.yaml index 0e2e1b72b..18b3c99ef 100644 --- a/pkg/lint/rules/testdata/albatross/templates/svc.yaml +++ b/pkg/lint/rules/testdata/albatross/templates/svc.yaml @@ -5,9 +5,9 @@ kind: Service metadata: name: "{{ .Values.name }}" labels: - heritage: {{ .Release.Service | quote }} - release: {{ .Release.Name | quote }} - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + app.kubernetes.io/managed-by: {{ .Release.Service | quote }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" kubeVersion: {{ .Capabilities.KubeVersion.Major }} spec: ports: From 4425f86865788df9bfed2fc26d6747775a65ff25 Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Wed, 27 Feb 2019 15:19:51 +0000 Subject: [PATCH 2/4] Add app.kubernetes.io/version label Signed-off-by: Luis Davim --- .../alpine/templates/alpine-pod.yaml | 1 + .../chart-bad-type/templates/alpine-pod.yaml | 3 +- .../novals/templates/alpine-pod.yaml | 1 + docs/chart_template_guide/variables.md | 1 + docs/charts_hooks.md | 1 + .../examples/alpine/templates/alpine-pod.yaml | 3 +- docs/examples/nginx/templates/configmap.yaml | 1 + docs/examples/nginx/templates/deployment.yaml | 1 + .../nginx/templates/post-install-job.yaml | 1 + .../nginx/templates/pre-install-secret.yaml | 1 + .../nginx/templates/service-test.yaml | 1 + docs/examples/nginx/templates/service.yaml | 1 + pkg/chartutil/create.go | 34 +++---------------- .../testdata/albatross/templates/svc.yaml | 1 + 14 files changed, 19 insertions(+), 32 deletions(-) diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml index 001c2cbbd..b48bb5e4f 100644 --- a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml @@ -10,6 +10,7 @@ metadata: # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{.Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml index ee61f2056..297d9a019 100644 --- a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml @@ -9,7 +9,8 @@ metadata: heritage: {{.Release.Service | quote }} # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - release: {{.Release.Name | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} diff --git a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml index f569d556c..564429dea 100644 --- a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml @@ -10,6 +10,7 @@ metadata: # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{.Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" annotations: diff --git a/docs/chart_template_guide/variables.md b/docs/chart_template_guide/variables.md index d924fe2cf..a2f017f92 100644 --- a/docs/chart_template_guide/variables.md +++ b/docs/chart_template_guide/variables.md @@ -117,6 +117,7 @@ metadata: # I cannot reference .Chart.Name, but I can do $.Chart.Name helm.sh/chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" app.kubernetes.io/instance: "{{ $.Release.Name }}" + app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/managed-by: "{{ $.Release.Service }}" type: kubernetes.io/tls data: diff --git a/docs/charts_hooks.md b/docs/charts_hooks.md index 042adc456..1284b9c2f 100644 --- a/docs/charts_hooks.md +++ b/docs/charts_hooks.md @@ -116,6 +116,7 @@ metadata: labels: app.kubernetes.io/managed-by: {{.Release.Service | quote }} app.kubernetes.io/instance: {{.Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" annotations: # This is what defines this resource as a hook. Without this line, the diff --git a/docs/examples/alpine/templates/alpine-pod.yaml b/docs/examples/alpine/templates/alpine-pod.yaml index beafd7668..2b54811fd 100644 --- a/docs/examples/alpine/templates/alpine-pod.yaml +++ b/docs/examples/alpine/templates/alpine-pod.yaml @@ -9,7 +9,8 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. - app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "alpine.name" . }} diff --git a/docs/examples/nginx/templates/configmap.yaml b/docs/examples/nginx/templates/configmap.yaml index 0141cbc69..d47992024 100644 --- a/docs/examples/nginx/templates/configmap.yaml +++ b/docs/examples/nginx/templates/configmap.yaml @@ -6,6 +6,7 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} data: diff --git a/docs/examples/nginx/templates/deployment.yaml b/docs/examples/nginx/templates/deployment.yaml index 08850935a..4a6211f62 100644 --- a/docs/examples/nginx/templates/deployment.yaml +++ b/docs/examples/nginx/templates/deployment.yaml @@ -13,6 +13,7 @@ metadata: # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} diff --git a/docs/examples/nginx/templates/post-install-job.yaml b/docs/examples/nginx/templates/post-install-job.yaml index 6e32086ab..1bb3e13f9 100644 --- a/docs/examples/nginx/templates/post-install-job.yaml +++ b/docs/examples/nginx/templates/post-install-job.yaml @@ -10,6 +10,7 @@ metadata: # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} diff --git a/docs/examples/nginx/templates/pre-install-secret.yaml b/docs/examples/nginx/templates/pre-install-secret.yaml index 07a9504b5..40451800d 100644 --- a/docs/examples/nginx/templates/pre-install-secret.yaml +++ b/docs/examples/nginx/templates/pre-install-secret.yaml @@ -7,6 +7,7 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} # This declares the resource to be a hook. By convention, we also name the diff --git a/docs/examples/nginx/templates/service-test.yaml b/docs/examples/nginx/templates/service-test.yaml index ffb37e9f4..867f077ee 100644 --- a/docs/examples/nginx/templates/service-test.yaml +++ b/docs/examples/nginx/templates/service-test.yaml @@ -5,6 +5,7 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} annotations: diff --git a/docs/examples/nginx/templates/service.yaml b/docs/examples/nginx/templates/service.yaml index 03f7aa2c6..0c26ad4f7 100644 --- a/docs/examples/nginx/templates/service.yaml +++ b/docs/examples/nginx/templates/service.yaml @@ -10,6 +10,7 @@ metadata: helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} name: {{ template "nginx.fullname" . }} spec: # Provides options for the service so chart users have the full choice diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 962a542e5..72150f4b3 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -159,6 +159,7 @@ metadata: app.kubernetes.io/name: {{ include ".name" . }} helm.sh/chart: {{ include ".chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- with .Values.ingress.annotations }} annotations: @@ -193,30 +194,15 @@ kind: Deployment metadata: name: {{ template ".fullname" . }} labels: -<<<<<<< HEAD - app: {{ template ".name" . }} - chart: {{ template ".chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -======= app.kubernetes.io/name: {{ include ".name" . }} helm.sh/chart: {{ include ".chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/managed-by: {{ .Release.Service }} ->>>>>>> e328d00a... Updating to the k8s label convention spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: -<<<<<<< HEAD - app: {{ template ".name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template ".name" . }} - release: {{ .Release.Name }} -======= app.kubernetes.io/name: {{ include ".name" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: @@ -224,7 +210,6 @@ spec: labels: app.kubernetes.io/name: {{ include ".name" . }} app.kubernetes.io/instance: {{ .Release.Name }} ->>>>>>> e328d00a... Updating to the k8s label convention spec: containers: - name: {{ .Chart.Name }} @@ -263,17 +248,11 @@ kind: Service metadata: name: {{ template ".fullname" . }} labels: -<<<<<<< HEAD - app: {{ template ".name" . }} - chart: {{ template ".chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -======= app.kubernetes.io/name: {{ include ".name" . }} helm.sh/chart: {{ include ".chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/managed-by: {{ .Release.Service }} ->>>>>>> e328d00a... Updating to the k8s label convention spec: type: {{ .Values.service.type }} ports: @@ -282,13 +261,8 @@ spec: protocol: TCP name: http selector: -<<<<<<< HEAD - app: {{ template ".name" . }} - release: {{ .Release.Name }} -======= app.kubernetes.io/name: {{ include ".name" . }} - app.kubernetes.io/instancelease: {{ .Release.Name }} ->>>>>>> e328d00a... Updating to the k8s label convention + app.kubernetes.io/instance: {{ .Release.Name }} ` const defaultNotes = `1. Get the application URL by running these commands: diff --git a/pkg/lint/rules/testdata/albatross/templates/svc.yaml b/pkg/lint/rules/testdata/albatross/templates/svc.yaml index 18b3c99ef..7ea916ed4 100644 --- a/pkg/lint/rules/testdata/albatross/templates/svc.yaml +++ b/pkg/lint/rules/testdata/albatross/templates/svc.yaml @@ -7,6 +7,7 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" kubeVersion: {{ .Capabilities.KubeVersion.Major }} spec: From 82ffe56ca67248772fef50a4c641afab3757423c Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Wed, 6 Mar 2019 12:45:57 +0000 Subject: [PATCH 3/4] Reduce template code duplication. Fixes #5372 Signed-off-by: Luis Davim --- .../testdata/testcharts/alpine/Chart.yaml | 1 + .../chart-bad-type/templates/alpine-pod.yaml | 1 - .../testdata/testcharts/novals/Chart.yaml | 1 + docs/chart_template_guide/variables.md | 3 +- .../examples/alpine/templates/alpine-pod.yaml | 2 +- docs/examples/nginx/templates/configmap.yaml | 1 - docs/examples/nginx/templates/deployment.yaml | 1 - .../nginx/templates/post-install-job.yaml | 1 - .../nginx/templates/pre-install-secret.yaml | 1 - .../nginx/templates/service-test.yaml | 1 - docs/examples/nginx/templates/service.yaml | 1 - pkg/chartutil/create.go | 33 ++++++++++--------- .../testdata/albatross/templates/svc.yaml | 1 - 13 files changed, 22 insertions(+), 26 deletions(-) diff --git a/cmd/helm/testdata/testcharts/alpine/Chart.yaml b/cmd/helm/testdata/testcharts/alpine/Chart.yaml index eec261220..7ee0b1122 100644 --- a/cmd/helm/testdata/testcharts/alpine/Chart.yaml +++ b/cmd/helm/testdata/testcharts/alpine/Chart.yaml @@ -1,4 +1,5 @@ apiVersion: v1 +appVersion: "3.3" description: Deploy a basic Alpine Linux pod home: https://helm.sh/helm name: alpine diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml index 297d9a019..eaf882385 100644 --- a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml @@ -10,7 +10,6 @@ metadata: # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{.Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} diff --git a/cmd/helm/testdata/testcharts/novals/Chart.yaml b/cmd/helm/testdata/testcharts/novals/Chart.yaml index ada85a4c4..a4282470b 100644 --- a/cmd/helm/testdata/testcharts/novals/Chart.yaml +++ b/cmd/helm/testdata/testcharts/novals/Chart.yaml @@ -5,3 +5,4 @@ name: novals sources: - https://github.com/helm/helm version: 0.2.0 +appVersion: 3.3 diff --git a/docs/chart_template_guide/variables.md b/docs/chart_template_guide/variables.md index a2f017f92..d7961d2a8 100644 --- a/docs/chart_template_guide/variables.md +++ b/docs/chart_template_guide/variables.md @@ -117,7 +117,8 @@ metadata: # I cannot reference .Chart.Name, but I can do $.Chart.Name helm.sh/chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" app.kubernetes.io/instance: "{{ $.Release.Name }}" - app.kubernetes.io/version: {{ .Chart.AppVersion }} + # Value from appVersion in Chart.yaml + app.kubernetes.io/version: "{{ $.Chart.AppVersion }}" app.kubernetes.io/managed-by: "{{ $.Release.Service }}" type: kubernetes.io/tls data: diff --git a/docs/examples/alpine/templates/alpine-pod.yaml b/docs/examples/alpine/templates/alpine-pod.yaml index 2b54811fd..0f48e4059 100644 --- a/docs/examples/alpine/templates/alpine-pod.yaml +++ b/docs/examples/alpine/templates/alpine-pod.yaml @@ -10,7 +10,7 @@ metadata: # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{ .Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "alpine.name" . }} diff --git a/docs/examples/nginx/templates/configmap.yaml b/docs/examples/nginx/templates/configmap.yaml index d47992024..0141cbc69 100644 --- a/docs/examples/nginx/templates/configmap.yaml +++ b/docs/examples/nginx/templates/configmap.yaml @@ -6,7 +6,6 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} data: diff --git a/docs/examples/nginx/templates/deployment.yaml b/docs/examples/nginx/templates/deployment.yaml index 4a6211f62..08850935a 100644 --- a/docs/examples/nginx/templates/deployment.yaml +++ b/docs/examples/nginx/templates/deployment.yaml @@ -13,7 +13,6 @@ metadata: # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} diff --git a/docs/examples/nginx/templates/post-install-job.yaml b/docs/examples/nginx/templates/post-install-job.yaml index 1bb3e13f9..6e32086ab 100644 --- a/docs/examples/nginx/templates/post-install-job.yaml +++ b/docs/examples/nginx/templates/post-install-job.yaml @@ -10,7 +10,6 @@ metadata: # The "app.kubernetes.io/instance" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} diff --git a/docs/examples/nginx/templates/pre-install-secret.yaml b/docs/examples/nginx/templates/pre-install-secret.yaml index 40451800d..07a9504b5 100644 --- a/docs/examples/nginx/templates/pre-install-secret.yaml +++ b/docs/examples/nginx/templates/pre-install-secret.yaml @@ -7,7 +7,6 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} # This declares the resource to be a hook. By convention, we also name the diff --git a/docs/examples/nginx/templates/service-test.yaml b/docs/examples/nginx/templates/service-test.yaml index 867f077ee..ffb37e9f4 100644 --- a/docs/examples/nginx/templates/service-test.yaml +++ b/docs/examples/nginx/templates/service-test.yaml @@ -5,7 +5,6 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/name: {{ template "nginx.name" . }} annotations: diff --git a/docs/examples/nginx/templates/service.yaml b/docs/examples/nginx/templates/service.yaml index 0c26ad4f7..03f7aa2c6 100644 --- a/docs/examples/nginx/templates/service.yaml +++ b/docs/examples/nginx/templates/service.yaml @@ -10,7 +10,6 @@ metadata: helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} name: {{ template "nginx.fullname" . }} spec: # Provides options for the service so chart users have the full choice diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 72150f4b3..18769b051 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -156,12 +156,8 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - app.kubernetes.io/name: {{ include ".name" . }} - helm.sh/chart: {{ include ".chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} +{{ include ".labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} annotations: {{ toYaml . | indent 4 }} {{- end }} @@ -194,11 +190,7 @@ kind: Deployment metadata: name: {{ template ".fullname" . }} labels: - app.kubernetes.io/name: {{ include ".name" . }} - helm.sh/chart: {{ include ".chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - app.kubernetes.io/managed-by: {{ .Release.Service }} +{{ include ".labels" . | indent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: @@ -248,11 +240,7 @@ kind: Service metadata: name: {{ template ".fullname" . }} labels: - app.kubernetes.io/name: {{ include ".name" . }} - helm.sh/chart: {{ include ".chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - app.kubernetes.io/managed-by: {{ .Release.Service }} +{{ include ".labels" . | indent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -318,6 +306,19 @@ Create chart name and version as used by the chart label. {{- define ".chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Common labels +*/}} +{{- define ".labels" -}} +app.kubernetes.io/name: {{ include ".name" . }} +helm.sh/chart: {{ include ".chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion -}} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end -}} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} ` // CreateFrom creates a new chart, but scaffolds it from the src chart. diff --git a/pkg/lint/rules/testdata/albatross/templates/svc.yaml b/pkg/lint/rules/testdata/albatross/templates/svc.yaml index 7ea916ed4..18b3c99ef 100644 --- a/pkg/lint/rules/testdata/albatross/templates/svc.yaml +++ b/pkg/lint/rules/testdata/albatross/templates/svc.yaml @@ -7,7 +7,6 @@ metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" kubeVersion: {{ .Capabilities.KubeVersion.Major }} spec: From 250b63eced1e9dbc9ca4b7a0758025c3a17d0f35 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 7 May 2019 14:13:29 -0400 Subject: [PATCH 4/4] Updating the labels for consistency Signed-off-by: Matt Farina --- .../output/template-name-template.txt | 14 +-- cmd/helm/testdata/output/template-set.txt | 14 +-- .../testdata/output/template-values-files.txt | 14 +-- cmd/helm/testdata/output/template.txt | 14 +-- .../testdata/testcharts/alpine/Chart.yaml | 2 +- .../alpine/templates/alpine-pod.yaml | 13 +-- .../chart-bad-type/templates/alpine-pod.yaml | 12 +-- .../templates/deployment.yaml | 16 ++-- .../chart-with-lib-dep/templates/ingress.yaml | 8 +- .../issue1979/templates/alpine-pod.yaml | 19 ++-- .../testdata/testcharts/lib-chart/README.md | 88 +++++++++---------- .../lib-chart/templates/_deployment.yaml | 4 +- .../lib-chart/templates/_metadata_labels.tpl | 8 +- .../lib-chart/templates/_service.yaml | 4 +- .../novals/templates/alpine-pod.yaml | 11 +-- .../charts/alpine/templates/alpine-pod.yaml | 19 ++-- .../charts/alpine/templates/alpine-pod.yaml | 8 +- .../charts/alpine/templates/alpine-pod.yaml | 8 +- .../charts/subchartA/templates/service.yaml | 4 +- .../charts/subchartB/templates/service.yaml | 4 +- .../charts/subchart1/templates/service.yaml | 6 +- .../charts/subchartB/templates/service.yaml | 4 +- .../charts/subchartC/templates/service.yaml | 4 +- .../charts/subchart2/templates/service.yaml | 4 +- .../subpop/noreqs/templates/service.yaml | 4 +- .../testdata/albatross/templates/svc.yaml | 2 +- 26 files changed, 156 insertions(+), 152 deletions(-) diff --git a/cmd/helm/testdata/output/template-name-template.txt b/cmd/helm/testdata/output/template-name-template.txt index 56105bb75..229ffe20f 100644 --- a/cmd/helm/testdata/output/template-name-template.txt +++ b/cmd/helm/testdata/output/template-name-template.txt @@ -5,7 +5,7 @@ kind: Service metadata: name: subcharta labels: - chart: "subcharta-0.1.0" + helm.sh/chart: "subcharta-0.1.0" spec: type: ClusterIP ports: @@ -14,7 +14,7 @@ spec: protocol: TCP name: apache selector: - app: subcharta + app.kubernetes.io/name: subcharta --- # Source: subchart1/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -22,7 +22,7 @@ kind: Service metadata: name: subchartb labels: - chart: "subchartb-0.1.0" + helm.sh/chart: "subchartb-0.1.0" spec: type: ClusterIP ports: @@ -31,7 +31,7 @@ spec: protocol: TCP name: nginx selector: - app: subchartb + app.kubernetes.io/name: subchartb --- # Source: subchart1/templates/service.yaml apiVersion: v1 @@ -39,8 +39,8 @@ kind: Service metadata: name: subchart1 labels: - chart: "subchart1-0.1.0" - release-name: "foobar-YWJj-baz" + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "foobar-YWJj-baz" kube-version/major: "1" kube-version/minor: "9" kube-version/gitversion: "v1.9.0" @@ -52,4 +52,4 @@ spec: protocol: TCP name: nginx selector: - app: subchart1 + app.kubernetes.io/name: subchart1 diff --git a/cmd/helm/testdata/output/template-set.txt b/cmd/helm/testdata/output/template-set.txt index 4e4643976..fec32bcae 100644 --- a/cmd/helm/testdata/output/template-set.txt +++ b/cmd/helm/testdata/output/template-set.txt @@ -5,7 +5,7 @@ kind: Service metadata: name: subcharta labels: - chart: "subcharta-0.1.0" + helm.sh/chart: "subcharta-0.1.0" spec: type: ClusterIP ports: @@ -14,7 +14,7 @@ spec: protocol: TCP name: apache selector: - app: subcharta + app.kubernetes.io/name: subcharta --- # Source: subchart1/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -22,7 +22,7 @@ kind: Service metadata: name: subchartb labels: - chart: "subchartb-0.1.0" + helm.sh/chart: "subchartb-0.1.0" spec: type: ClusterIP ports: @@ -31,7 +31,7 @@ spec: protocol: TCP name: nginx selector: - app: subchartb + app.kubernetes.io/name: subchartb --- # Source: subchart1/templates/service.yaml apiVersion: v1 @@ -39,8 +39,8 @@ kind: Service metadata: name: subchart1 labels: - chart: "subchart1-0.1.0" - release-name: "RELEASE-NAME" + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" kube-version/major: "1" kube-version/minor: "9" kube-version/gitversion: "v1.9.0" @@ -52,4 +52,4 @@ spec: protocol: TCP name: apache selector: - app: subchart1 + app.kubernetes.io/name: subchart1 diff --git a/cmd/helm/testdata/output/template-values-files.txt b/cmd/helm/testdata/output/template-values-files.txt index 4e4643976..fec32bcae 100644 --- a/cmd/helm/testdata/output/template-values-files.txt +++ b/cmd/helm/testdata/output/template-values-files.txt @@ -5,7 +5,7 @@ kind: Service metadata: name: subcharta labels: - chart: "subcharta-0.1.0" + helm.sh/chart: "subcharta-0.1.0" spec: type: ClusterIP ports: @@ -14,7 +14,7 @@ spec: protocol: TCP name: apache selector: - app: subcharta + app.kubernetes.io/name: subcharta --- # Source: subchart1/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -22,7 +22,7 @@ kind: Service metadata: name: subchartb labels: - chart: "subchartb-0.1.0" + helm.sh/chart: "subchartb-0.1.0" spec: type: ClusterIP ports: @@ -31,7 +31,7 @@ spec: protocol: TCP name: nginx selector: - app: subchartb + app.kubernetes.io/name: subchartb --- # Source: subchart1/templates/service.yaml apiVersion: v1 @@ -39,8 +39,8 @@ kind: Service metadata: name: subchart1 labels: - chart: "subchart1-0.1.0" - release-name: "RELEASE-NAME" + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" kube-version/major: "1" kube-version/minor: "9" kube-version/gitversion: "v1.9.0" @@ -52,4 +52,4 @@ spec: protocol: TCP name: apache selector: - app: subchart1 + app.kubernetes.io/name: subchart1 diff --git a/cmd/helm/testdata/output/template.txt b/cmd/helm/testdata/output/template.txt index 40b05a1f6..c0ddca8d8 100644 --- a/cmd/helm/testdata/output/template.txt +++ b/cmd/helm/testdata/output/template.txt @@ -5,7 +5,7 @@ kind: Service metadata: name: subcharta labels: - chart: "subcharta-0.1.0" + helm.sh/chart: "subcharta-0.1.0" spec: type: ClusterIP ports: @@ -14,7 +14,7 @@ spec: protocol: TCP name: apache selector: - app: subcharta + app.kubernetes.io/name: subcharta --- # Source: subchart1/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -22,7 +22,7 @@ kind: Service metadata: name: subchartb labels: - chart: "subchartb-0.1.0" + helm.sh/chart: "subchartb-0.1.0" spec: type: ClusterIP ports: @@ -31,7 +31,7 @@ spec: protocol: TCP name: nginx selector: - app: subchartb + app.kubernetes.io/name: subchartb --- # Source: subchart1/templates/service.yaml apiVersion: v1 @@ -39,8 +39,8 @@ kind: Service metadata: name: subchart1 labels: - chart: "subchart1-0.1.0" - release-name: "RELEASE-NAME" + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" kube-version/major: "1" kube-version/minor: "9" kube-version/gitversion: "v1.9.0" @@ -52,4 +52,4 @@ spec: protocol: TCP name: nginx selector: - app: subchart1 + app.kubernetes.io/name: subchart1 diff --git a/cmd/helm/testdata/testcharts/alpine/Chart.yaml b/cmd/helm/testdata/testcharts/alpine/Chart.yaml index 7ee0b1122..1d6bad825 100644 --- a/cmd/helm/testdata/testcharts/alpine/Chart.yaml +++ b/cmd/helm/testdata/testcharts/alpine/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "3.3" +appVersion: "3.9" description: Deploy a basic Alpine Linux pod home: https://helm.sh/helm name: alpine diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml index b48bb5e4f..ae19a1127 100644 --- a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml @@ -3,12 +3,13 @@ kind: Pod metadata: name: "{{.Release.Name}}-{{.Values.Name}}" labels: - # The "heritage" label is used to track which tool deployed a given chart. - # It is useful for admins who want to see what releases a particular tool - # is responsible for. + # The "app.kubernetes.io/managed-by" label is used to track which tool + # deployed a given chart. It is useful for admins who want to see what + # releases a particular tool is responsible for. app.kubernetes.io/managed-by: {{.Release.Service | quote }} - # The "release" convention makes it easy to tie a release to all of the - # Kubernetes resources that were created as part of that release. + # The "app.kubernetes.io/instance" convention makes it easy to tie a release + # to all of the Kubernetes resources that were created as part of that + # release. app.kubernetes.io/instance: {{.Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. @@ -22,5 +23,5 @@ spec: restartPolicy: {{default "Never" .Values.restartPolicy}} containers: - name: waiter - image: "alpine:3.3" + image: "alpine:{{ .Chart.AppVersion }}" command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml index eaf882385..a40ae32d7 100644 --- a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml @@ -3,15 +3,15 @@ kind: Pod metadata: name: "{{.Release.Name}}-{{.Values.Name}}" labels: - # The "heritage" label is used to track which tool deployed a given chart. - # It is useful for admins who want to see what releases a particular tool - # is responsible for. - heritage: {{.Release.Service | quote }} + # The "app.kubernetes.io/managed-by" label is used to track which tool + # deployed a given chart. It is useful for admins who want to see what + # releases a particular tool is responsible for. + app.kubernetes.io/managed-by: {{.Release.Service | quote }} # The "release" convention makes it easy to tie a release to all of the # Kubernetes resources that were created as part of that release. app.kubernetes.io/instance: {{.Release.Name | quote }} # This makes it easy to audit chart usage. - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} spec: # This shows how to use a simple value. This will look for a passed-in value @@ -21,5 +21,5 @@ spec: restartPolicy: {{default "Never" .Values.restartPolicy}} containers: - name: waiter - image: "alpine:3.3" + image: "alpine:3.9" command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml index ff63aefc2..18b4f8718 100644 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml +++ b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml @@ -3,21 +3,21 @@ kind: Deployment metadata: name: {{ template "chart-with-lib-dep.fullname" . }} labels: - app: {{ template "chart-with-lib-dep.name" . }} - chart: {{ template "chart-with-lib-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} + helm.sh/chart: {{ template "chart-with-lib-dep.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - app: {{ template "chart-with-lib-dep.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: labels: - app: {{ template "chart-with-lib-dep.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} spec: containers: - name: {{ .Chart.Name }} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml index 0330f2fef..42afd0879 100644 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml +++ b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml @@ -6,10 +6,10 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - app: {{ template "chart-with-lib-dep.name" . }} - chart: {{ template "chart-with-lib-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} + helm.sh/chart: {{ template "chart-with-lib-dep.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} {{- with .Values.ingress.annotations }} annotations: {{ toYaml . | indent 4 }} diff --git a/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml index ee61f2056..6f025fecb 100644 --- a/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml @@ -3,15 +3,16 @@ kind: Pod metadata: name: "{{.Release.Name}}-{{.Values.Name}}" labels: - # The "heritage" label is used to track which tool deployed a given chart. - # It is useful for admins who want to see what releases a particular tool - # is responsible for. - heritage: {{.Release.Service | quote }} - # The "release" convention makes it easy to tie a release to all of the - # Kubernetes resources that were created as part of that release. - release: {{.Release.Name | quote }} + # The "app.kubernetes.io/managed-by" label is used to track which tool + # deployed a given chart. It is useful for admins who want to see what + # releases a particular tool is responsible for. + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + # The "app.kubernetes.io/instance" convention makes it easy to tie a release + # to all of the Kubernetes resources that were created as part of that + # release. + app.kubernetes.io/instance: {{.Release.Name | quote }} # This makes it easy to audit chart usage. - chart: "{{.Chart.Name}}-{{.Chart.Version}}" + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" values: {{.Values.test.Name}} spec: # This shows how to use a simple value. This will look for a passed-in value @@ -21,5 +22,5 @@ spec: restartPolicy: {{default "Never" .Values.restartPolicy}} containers: - name: waiter - image: "alpine:3.3" + image: "alpine:3.9" command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/lib-chart/README.md b/cmd/helm/testdata/testcharts/lib-chart/README.md index ca0459474..aca257924 100644 --- a/cmd/helm/testdata/testcharts/lib-chart/README.md +++ b/cmd/helm/testdata/testcharts/lib-chart/README.md @@ -65,7 +65,7 @@ following defaults: - Service type (ClusterIP, NodePort, LoadBalancer) made configurable by `.Values.service.type` - Named port `http` configured on port 80 -- Selector set to `app: {{ template "common.name" }}, release: {{ .Release.Name | quote }}` to match the default used in the `Deployment` resource +- Selector set to `app.kubernetes.io/name: {{ template "common.name" }}, app.kubernetes.io/instance: {{ .Release.Name | quote }}` to match the default used in the `Deployment` resource Example template: @@ -115,11 +115,11 @@ apiVersion: v1 kind: Service metadata: labels: - app: service - chart: service-0.1.0 - heritage: Tiller + app.kubernetes.io/name: service + helm.sh/chart: service-0.1.0 + app.kubernetes.io/managed-by: Helm protocol: mail - release: release-name + app.kubernetes.io/instance: release-name name: release-name-service-mail spec: ports: @@ -130,8 +130,8 @@ spec: port: 993 targetPort: 993 selector: - app: service - release: release-name + app.kubernetes.io/name: service + app.kubernetes.io/instance: release-name protocol: mail type: ClusterIP --- @@ -139,11 +139,11 @@ apiVersion: v1 kind: Service metadata: labels: - app: service - chart: service-0.1.0 - heritage: Tiller + app.kubernetes.io/name: service + helm.sh/chart: service-0.1.0 + app.kubernetes.io/managed-by: Helm protocol: www - release: release-name + app.kubernetes.io/instance: release-name name: release-name-service-www spec: ports: @@ -250,16 +250,16 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: - app: deployment - chart: deployment-0.1.0 - heritage: Tiller - release: release-name + app.kubernetes.io/name: deployment + helm.sh/chart: deployment-0.1.0 + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/instance: release-name name: release-name-deployment spec: template: metadata: labels: - app: deployment + app.kubernetes.io/name: deployment spec: containers: - image: nginx:stable @@ -316,10 +316,10 @@ data: kind: ConfigMap metadata: labels: - app: configmap - chart: configmap-0.1.0 - heritage: Tiller - release: release-name + app.kubernetes.io/name: configmap + helm.sh/chart: configmap-0.1.0 + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/instance: release-name name: release-name-configmap ``` @@ -354,10 +354,10 @@ data: kind: Secret metadata: labels: - app: secret - chart: secret-0.1.0 - heritage: Tiller - release: release-name + app.kubernetes.io/name: secret + helm.sh/chart: secret-0.1.0 + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/instance: release-name name: release-name-secret type: Opaque ``` @@ -399,10 +399,10 @@ metadata: kubernetes.io/ingress.class: nginx kubernetes.io/tls-acme: "true" labels: - app: ingress - chart: ingress-0.1.0 - heritage: Tiller - release: release-name + app.kubernetes.io/name: ingress + helm.sh/chart: ingress-0.1.0 + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/instance: release-name name: release-name-ingress spec: rules: @@ -459,10 +459,10 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: - app: persistentvolumeclaim - chart: persistentvolumeclaim-0.1.0 - heritage: Tiller - release: release-name + app.kubernetes.io/name: persistentvolumeclaim + helm.sh/chart: persistentvolumeclaim-0.1.0 + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/instance: release-name name: release-name-persistentvolumeclaim spec: accessModes: @@ -731,10 +731,10 @@ Example output: metadata: name: release-name-metadata labels: - app: metadata - heritage: "Tiller" - release: "RELEASE-NAME" - chart: metadata-0.1.0 + app.kubernetes.io/name: metadata + app.kubernetes.io/managed-by: "Helm" + app.kubernetes.io/instance: "RELEASE-NAME" + helm.sh/chart: metadata-0.1.0 first: "matt" last: "butcher" nick: "technosophos" @@ -746,10 +746,10 @@ metadata: metadata: name: Zeus labels: - app: metadata - heritage: "Tiller" - release: "RELEASE-NAME" - chart: metadata-0.1.0 + app.kubernetes.io/name: metadata + app.kubernetes.io/managed-by: "Helm" + app.kubernetes.io/instance: "RELEASE-NAME" + helm.sh/chart: metadata-0.1.0 annotations: ``` @@ -789,10 +789,10 @@ Example usage: Example output: ```yaml -app: labelizer -heritage: "Tiller" -release: "RELEASE-NAME" -chart: labelizer-0.1.0 +app.kubernetes.io/name: labelizer +app.kubernetes.io/managed-by: "Tiller" +app.kubernetes.io/instance: "RELEASE-NAME" +helm.sh/chart: labelizer-0.1.0 ``` ### `common.hook` diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml index c49dae3eb..e99a8cd33 100644 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml +++ b/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml @@ -6,8 +6,8 @@ spec: template: metadata: labels: - app: {{ template "common.name" . }} - release: {{ .Release.Name | quote }} + app.kubernetes.io/name: {{ template "common.name" . }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} spec: containers: - diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl index 15fe00c5f..bcb8cdaa8 100644 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl +++ b/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl @@ -21,8 +21,8 @@ common.labels.standard prints the standard Helm labels. The standard labels are frequently used in metadata. */ -}} {{- define "common.labels.standard" -}} -app: {{ template "common.name" . }} -chart: {{ template "common.chartref" . }} -heritage: {{ .Release.Service | quote }} -release: {{ .Release.Name | quote }} +app.kubernetes.io/name: {{ template "common.name" . }} +helm.sh/chart: {{ template "common.chartref" . }} +app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml index 67379525f..b9dfc378a 100644 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml +++ b/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml @@ -9,8 +9,8 @@ spec: port: 80 targetPort: http selector: - app: {{ template "common.name" . }} - release: {{ .Release.Name | quote }} + app.kubernetes.io/name: {{ template "common.name" . }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- end -}} {{- define "common.service" -}} {{- template "common.util.merge" (append . "common.service.tpl") -}} diff --git a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml index 564429dea..96c92d61d 100644 --- a/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/novals/templates/alpine-pod.yaml @@ -3,12 +3,13 @@ kind: Pod metadata: name: "{{.Release.Name}}-{{.Values.Name}}" labels: - # The "heritage" label is used to track which tool deployed a given chart. - # It is useful for admins who want to see what releases a particular tool - # is responsible for. + # The "app.kubernetes.io/managed-by" label is used to track which tool + # deployed a given chart. It is useful for admins who want to see what + # releases a particular tool is responsible for. app.kubernetes.io/managed-by: {{.Release.Service | quote }} - # The "release" convention makes it easy to tie a release to all of the - # Kubernetes resources that were created as part of that release. + # The "app.kubernetes.io/instance" convention makes it easy to tie a release + # to all of the Kubernetes resources that were created as part of that + # release. app.kubernetes.io/instance: {{.Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. diff --git a/docs/examples/nginx/charts/alpine/templates/alpine-pod.yaml b/docs/examples/nginx/charts/alpine/templates/alpine-pod.yaml index da9caef78..a1a5f15da 100644 --- a/docs/examples/nginx/charts/alpine/templates/alpine-pod.yaml +++ b/docs/examples/nginx/charts/alpine/templates/alpine-pod.yaml @@ -3,16 +3,17 @@ kind: Pod metadata: name: {{ template "alpine.fullname" . }} labels: - # The "heritage" label is used to track which tool deployed a given chart. - # It is useful for admins who want to see what releases a particular tool - # is responsible for. - heritage: {{ .Release.Service }} - # The "release" convention makes it easy to tie a release to all of the - # Kubernetes resources that were created as part of that release. - release: {{ .Release.Name }} + # The "app.kubernetes.io/managed-by" label is used to track which tool + # deployed a given chart. It is useful for admins who want to see what + # releases a particular tool is responsible for. + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + # The "app.kubernetes.io/instance" convention makes it easy to tie a release + # to all of the Kubernetes resources that were created as part of that + # release. + app.kubernetes.io/instance: {{.Release.Name | quote }} # This makes it easy to audit chart usage. - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "alpine.name" . }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" + app.kubernetes.io/name: {{ template "alpine.name" . }} spec: # This shows how to use a simple value. This will look for a passed-in value called restartPolicy. restartPolicy: {{ .Values.restartPolicy }} diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..21ae20aad 100644 --- a/pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml @@ -3,12 +3,12 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} - chartName: {{.Chart.Name}} - chartVersion: {{.Chart.Version | quote}} + app.kubernetes.io/managed-by: {{.Release.Service}} + app.kubernetes.io/name: {{.Chart.Name}} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" spec: restartPolicy: {{default "Never" .restart_policy}} containers: - name: waiter - image: "alpine:3.3" + image: "alpine:3.9" command: ["/bin/sleep","9000"] diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml index 0c6980cf7..0ac5ca6a8 100755 --- a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml +++ b/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml @@ -3,12 +3,12 @@ kind: Pod metadata: name: {{.Release.Name}}-{{.Chart.Name}} labels: - heritage: {{.Release.Service}} - chartName: {{.Chart.Name}} - chartVersion: {{.Chart.Version | quote}} + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/name: {{.Chart.Name}} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" spec: restartPolicy: {{default "Never" .restart_policy}} containers: - name: waiter - image: "alpine:3.3" + image: "alpine:3.9" command: ["/bin/sleep","9000"] diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml index fdf75aa91..27501e1e0 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml index fdf75aa91..27501e1e0 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml index 3c6395ef4..0ce52ac43 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml @@ -3,8 +3,8 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release-name: "{{ .Release.Name }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + app.kubernetes.io/instance: "{{ .Release.Name }}" kube-version/major: "{{ .Capabilities.KubeVersion.Major }}" kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}" kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0" @@ -16,4 +16,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml index 0935aadce..3f168bdbf 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: subchart2-{{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/hart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: subchart2-{{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml index fdf75aa91..27501e1e0 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml b/pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml index fdf75aa91..27501e1e0 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml b/pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml index fdf75aa91..27501e1e0 100644 --- a/pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml +++ b/pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ .Chart.Name }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ .Chart.Name }} + app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/pkg/lint/rules/testdata/albatross/templates/svc.yaml b/pkg/lint/rules/testdata/albatross/templates/svc.yaml index 18b3c99ef..16bb27d55 100644 --- a/pkg/lint/rules/testdata/albatross/templates/svc.yaml +++ b/pkg/lint/rules/testdata/albatross/templates/svc.yaml @@ -16,4 +16,4 @@ spec: protocol: TCP name: http selector: - app: {{template "fullname" .}} + app.kubernetes.io/name: {{template "fullname" .}}