diff --git a/charts/podinfo/Chart.yaml b/charts/podinfo/Chart.yaml index bd0c374..9373950 100644 --- a/charts/podinfo/Chart.yaml +++ b/charts/podinfo/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -version: 4.0.6 +version: 5.0.0 appVersion: 4.0.6 name: podinfo engine: gotpl diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index b0bff2a..7786e91 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -104,3 +104,14 @@ $ helm install my-release podinfo/podinfo -f values.yaml ``` > **Tip**: You can use the default [values.yaml](values.yaml) + +## Upgrading the chart + +### To =< 5.0.0 + +Version 5.0.0 is a major update. + +* The chart now follows the new Kubernetes label recommendations: + + +The simplest way to update is to do a force upgrade, which recreates the resources by doing a delete and an install. diff --git a/charts/podinfo/templates/_helpers.tpl b/charts/podinfo/templates/_helpers.tpl index 7991e94..d7d723f 100644 --- a/charts/podinfo/templates/_helpers.tpl +++ b/charts/podinfo/templates/_helpers.tpl @@ -1,10 +1,9 @@ -{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "podinfo.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -12,32 +11,52 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "podinfo.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} {{/* Create chart name and version as used by the chart label. */}} {{- define "podinfo.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "podinfo.labels" -}} +helm.sh/chart: {{ include "podinfo.chart" . }} +{{ include "podinfo.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "podinfo.selectorLabels" -}} +app.kubernetes.io/name: {{ include "podinfo.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} {{/* Create the name of the service account to use */}} {{- define "podinfo.serviceAccountName" -}} -{{- if .Values.serviceAccount.enabled -}} - {{ default (include "podinfo.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} \ No newline at end of file +{{- if .Values.serviceAccount.create }} +{{- default (include "podinfo.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml index 141ca15..56c6942 100644 --- a/charts/podinfo/templates/deployment.yaml +++ b/charts/podinfo/templates/deployment.yaml @@ -3,10 +3,7 @@ kind: Deployment metadata: name: {{ template "podinfo.fullname" . }} labels: - app: {{ template "podinfo.fullname" . }} - chart: {{ template "podinfo.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "podinfo.labels" . | nindent 4 }} spec: {{- if not .Values.hpa.enabled }} replicas: {{ .Values.replicaCount }} @@ -17,11 +14,11 @@ spec: maxUnavailable: 1 selector: matchLabels: - app: {{ template "podinfo.fullname" . }} + {{- include "podinfo.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: {{ template "podinfo.fullname" . }} + {{- include "podinfo.selectorLabels" . | nindent 8 }} annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.service.httpPort }}" diff --git a/charts/podinfo/templates/hpa.yaml b/charts/podinfo/templates/hpa.yaml index 14ec069..a83d201 100644 --- a/charts/podinfo/templates/hpa.yaml +++ b/charts/podinfo/templates/hpa.yaml @@ -3,6 +3,8 @@ apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: {{ template "podinfo.fullname" . }} + labels: + {{- include "podinfo.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/charts/podinfo/templates/ingress.yaml b/charts/podinfo/templates/ingress.yaml index 33d423c..b4ef94c 100644 --- a/charts/podinfo/templates/ingress.yaml +++ b/charts/podinfo/templates/ingress.yaml @@ -6,10 +6,7 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - app: {{ template "podinfo.name" . }} - chart: {{ template "podinfo.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "podinfo.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{ toYaml . | indent 4 }} diff --git a/charts/podinfo/templates/linkerd.yaml b/charts/podinfo/templates/linkerd.yaml index 21e5970..a96e091 100644 --- a/charts/podinfo/templates/linkerd.yaml +++ b/charts/podinfo/templates/linkerd.yaml @@ -3,6 +3,8 @@ apiVersion: linkerd.io/v1alpha2 kind: ServiceProfile metadata: name: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + labels: + {{- include "podinfo.labels" . | nindent 4 }} spec: routes: - condition: diff --git a/charts/podinfo/templates/service.yaml b/charts/podinfo/templates/service.yaml index 2780d44..c794b43 100644 --- a/charts/podinfo/templates/service.yaml +++ b/charts/podinfo/templates/service.yaml @@ -4,10 +4,7 @@ kind: Service metadata: name: {{ template "podinfo.fullname" . }} labels: - app: {{ template "podinfo.name" . }} - chart: {{ template "podinfo.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "podinfo.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -25,5 +22,5 @@ spec: name: grpc {{- end }} selector: - app: {{ template "podinfo.fullname" . }} -{{- end }} \ No newline at end of file + {{- include "podinfo.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/podinfo/templates/serviceaccount.yaml b/charts/podinfo/templates/serviceaccount.yaml index 0de8a1c..7a55ea8 100644 --- a/charts/podinfo/templates/serviceaccount.yaml +++ b/charts/podinfo/templates/serviceaccount.yaml @@ -4,8 +4,5 @@ kind: ServiceAccount metadata: name: {{ template "podinfo.serviceAccountName" . }} labels: - app: {{ template "podinfo.name" . }} - chart: {{ template "podinfo.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "podinfo.labels" . | nindent 4 }} {{- end -}} diff --git a/charts/podinfo/templates/servicemonitor.yaml b/charts/podinfo/templates/servicemonitor.yaml index 22bad16..ae51355 100644 --- a/charts/podinfo/templates/servicemonitor.yaml +++ b/charts/podinfo/templates/servicemonitor.yaml @@ -4,10 +4,7 @@ kind: ServiceMonitor metadata: name: {{ template "podinfo.fullname" . }} labels: - app: {{ template "podinfo.name" . }} - chart: {{ template "podinfo.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "podinfo.labels" . | nindent 4 }} spec: endpoints: - path: /metrics