From e8a1feff501733d20432e6834435a26721f565af Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Wed, 6 Dec 2023 11:40:12 +0100 Subject: [PATCH 1/2] Update: Kubernetes recommanded labels Signed-off-by: Nicolas Lamirault --- charts/podinfo/templates/_helpers.tpl | 2 ++ charts/podinfo/templates/certificate.yaml | 1 + charts/podinfo/templates/deployment.yaml | 4 +++- charts/podinfo/templates/hpa.yaml | 3 ++- charts/podinfo/templates/ingress.yaml | 1 + charts/podinfo/templates/linkerd.yaml | 3 ++- charts/podinfo/templates/service.yaml | 1 + charts/podinfo/templates/serviceaccount.yaml | 1 + charts/podinfo/templates/servicemonitor.yaml | 1 + 9 files changed, 14 insertions(+), 3 deletions(-) diff --git a/charts/podinfo/templates/_helpers.tpl b/charts/podinfo/templates/_helpers.tpl index c691994e..d383ef0e 100644 --- a/charts/podinfo/templates/_helpers.tpl +++ b/charts/podinfo/templates/_helpers.tpl @@ -36,6 +36,8 @@ Common labels {{- define "podinfo.labels" -}} helm.sh/chart: {{ include "podinfo.chart" . }} {{ include "podinfo.selectorLabels" . }} +app.kubernetes.io/instance: podinfo +app.kubernetes.io/part-of: podinfo {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} diff --git a/charts/podinfo/templates/certificate.yaml b/charts/podinfo/templates/certificate.yaml index 8b238092..3c7bc498 100644 --- a/charts/podinfo/templates/certificate.yaml +++ b/charts/podinfo/templates/certificate.yaml @@ -5,6 +5,7 @@ metadata: name: {{ template "podinfo.fullname" . }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: certificate spec: dnsNames: {{- range .Values.certificate.dnsNames }} diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml index 87ed3735..ebcbcc90 100644 --- a/charts/podinfo/templates/deployment.yaml +++ b/charts/podinfo/templates/deployment.yaml @@ -4,6 +4,7 @@ metadata: name: {{ template "podinfo.fullname" . }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: application spec: {{- if not .Values.hpa.enabled }} replicas: {{ .Values.replicaCount }} @@ -18,7 +19,8 @@ spec: template: metadata: labels: - {{- include "podinfo.selectorLabels" . | nindent 8 }} + {{- include "podinfo.labels" . | nindent 8 }} + app.kubernetes.io/component: application 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 6d768ae0..e7103ef4 100644 --- a/charts/podinfo/templates/hpa.yaml +++ b/charts/podinfo/templates/hpa.yaml @@ -4,7 +4,8 @@ kind: HorizontalPodAutoscaler metadata: name: {{ template "podinfo.fullname" . }} labels: - {{- include "podinfo.labels" . | nindent 4 }} + {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: autoscaling spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/charts/podinfo/templates/ingress.yaml b/charts/podinfo/templates/ingress.yaml index bae38eb2..3db244bc 100644 --- a/charts/podinfo/templates/ingress.yaml +++ b/charts/podinfo/templates/ingress.yaml @@ -7,6 +7,7 @@ metadata: name: {{ $fullName }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: networking {{- with .Values.ingress.additionalLabels }} {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/podinfo/templates/linkerd.yaml b/charts/podinfo/templates/linkerd.yaml index a96e0919..b13717c3 100644 --- a/charts/podinfo/templates/linkerd.yaml +++ b/charts/podinfo/templates/linkerd.yaml @@ -4,7 +4,8 @@ kind: ServiceProfile metadata: name: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local labels: - {{- include "podinfo.labels" . | nindent 4 }} + {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: networking spec: routes: - condition: diff --git a/charts/podinfo/templates/service.yaml b/charts/podinfo/templates/service.yaml index 6014e788..df19e507 100644 --- a/charts/podinfo/templates/service.yaml +++ b/charts/podinfo/templates/service.yaml @@ -5,6 +5,7 @@ metadata: name: {{ template "podinfo.fullname" . }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: networking {{- with .Values.service.annotations }} annotations: {{ toYaml . | indent 4 }} diff --git a/charts/podinfo/templates/serviceaccount.yaml b/charts/podinfo/templates/serviceaccount.yaml index 72ff524d..e06732a0 100644 --- a/charts/podinfo/templates/serviceaccount.yaml +++ b/charts/podinfo/templates/serviceaccount.yaml @@ -5,6 +5,7 @@ metadata: name: {{ template "podinfo.serviceAccountName" . }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac {{- with .Values.serviceAccount.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 2 }} diff --git a/charts/podinfo/templates/servicemonitor.yaml b/charts/podinfo/templates/servicemonitor.yaml index fa0c3445..198748e7 100644 --- a/charts/podinfo/templates/servicemonitor.yaml +++ b/charts/podinfo/templates/servicemonitor.yaml @@ -5,6 +5,7 @@ metadata: name: {{ template "podinfo.fullname" . }} labels: {{- include "podinfo.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics {{- with .Values.serviceMonitor.additionalLabels }} {{- toYaml . | nindent 4 }} {{- end }} From bf986836ead6164d5c15a5c9b9ffa4e2d36d85f8 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Wed, 6 Dec 2023 11:42:38 +0100 Subject: [PATCH 2/2] Add: support additional labels Signed-off-by: Nicolas Lamirault --- charts/podinfo/templates/_helpers.tpl | 3 +++ charts/podinfo/values.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/charts/podinfo/templates/_helpers.tpl b/charts/podinfo/templates/_helpers.tpl index d383ef0e..8789ff88 100644 --- a/charts/podinfo/templates/_helpers.tpl +++ b/charts/podinfo/templates/_helpers.tpl @@ -42,6 +42,9 @@ app.kubernetes.io/part-of: podinfo app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.additionalLabels }} +{{ toYaml .Values.additionalLabels }} +{{- end }} {{- end }} {{/* diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index 6a4c4206..71e4bc15 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -16,6 +16,10 @@ ui: message: "" logo: "" +# -- Labels to be added to all other resources. +additionalLabels: {} + # app: podinfo + # failure conditions faults: delay: false