From 23a61053088eb34d6fe1945a71cd0f4e2383c50e Mon Sep 17 00:00:00 2001 From: Liam Mackie Date: Mon, 29 Jul 2024 20:25:37 +1000 Subject: [PATCH] Unify and use standard labels - Fixes #8 --- .../octopus-deploy/charts/mssql/templates/_helpers.tpl | 2 +- charts/octopus-deploy/templates/_helpers.tpl | 10 +++++----- charts/octopus-deploy/templates/dockerHubSecret.yaml | 5 +---- charts/octopus-deploy/templates/ingress.yaml | 10 ++-------- charts/octopus-deploy/templates/role.yaml | 5 +---- charts/octopus-deploy/templates/rolebinding.yml | 5 +---- charts/octopus-deploy/templates/serviceaccount.yaml | 5 +---- 7 files changed, 12 insertions(+), 30 deletions(-) diff --git a/charts/octopus-deploy/charts/mssql/templates/_helpers.tpl b/charts/octopus-deploy/charts/mssql/templates/_helpers.tpl index 0d707118..6f3d3493 100644 --- a/charts/octopus-deploy/charts/mssql/templates/_helpers.tpl +++ b/charts/octopus-deploy/charts/mssql/templates/_helpers.tpl @@ -29,7 +29,7 @@ If release name contains chart name it will be used as a full name. {{/* Selector Labels for mssql */}} {{- define "mssql.selectorLabels" -}} {{include "labels" . }} -component: mssql +app.kubernetes.io/component: mssql {{- end -}} {{- define "mssql.storageClass" -}} diff --git a/charts/octopus-deploy/templates/_helpers.tpl b/charts/octopus-deploy/templates/_helpers.tpl index c80c90e5..dbdf34b9 100644 --- a/charts/octopus-deploy/templates/_helpers.tpl +++ b/charts/octopus-deploy/templates/_helpers.tpl @@ -35,16 +35,16 @@ Create chart name and version as used by the chart label. Common Labels */}} {{- define "labels" -}} -app: {{ include "octopus.name" . }} -chart: {{ include "octopus.chart" . }} -release: {{ .Release.Name }} -heritage: {{ .Release.Service }} +app.kubernetes.io/name: {{ include "octopus.name" . }} +helm.sh/chart: {{ include "octopus.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} {{/* Selector Labels for octopus */}} {{- define "octopus.selectorLabels" -}} {{include "labels" . }} -component: octopus-server +app.kubernetes.io/component: octopus-server {{- end -}} {{/* diff --git a/charts/octopus-deploy/templates/dockerHubSecret.yaml b/charts/octopus-deploy/templates/dockerHubSecret.yaml index d59f1193..0c64c382 100644 --- a/charts/octopus-deploy/templates/dockerHubSecret.yaml +++ b/charts/octopus-deploy/templates/dockerHubSecret.yaml @@ -4,10 +4,7 @@ kind: Secret metadata: name: dockerhubcreds labels: - app: {{ template "octopus.name" . }} - chart: {{ template "octopus.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "labels" . | nindent 4 }} data: .dockerconfigjson: {{.Values.dockerHub.creds}} type: kubernetes.io/dockerconfigjson diff --git a/charts/octopus-deploy/templates/ingress.yaml b/charts/octopus-deploy/templates/ingress.yaml index cef4a316..2545ceab 100644 --- a/charts/octopus-deploy/templates/ingress.yaml +++ b/charts/octopus-deploy/templates/ingress.yaml @@ -5,10 +5,7 @@ kind: Ingress metadata: name: {{ $name }} labels: - app: {{ template "octopus.name" . }} - chart: {{ template "octopus.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "labels" . | nindent 4 }} {{- if .Values.octopus.ingress.labels }} {{ toYaml .Values.octopus.ingress.labels | indent 4 }} {{- end }} @@ -56,10 +53,7 @@ kind: Ingress metadata: name: octopus-deploy-polling-node{{ . }} labels: - app: {{ template "octopus.name" $ }} - chart: {{ template "octopus.chart" $ }} - release: {{ $.Release.Name }} - heritage: {{ $.Release.Service }} + {{- include "labels" . | nindent 4 }} {{- if $.Values.octopus.ingress.pollingTentacles.labels }} {{ toYaml $.Values.octopus.ingress.pollingTentacles.labels | indent 4 }} {{- end }} diff --git a/charts/octopus-deploy/templates/role.yaml b/charts/octopus-deploy/templates/role.yaml index 2840a832..617e712a 100644 --- a/charts/octopus-deploy/templates/role.yaml +++ b/charts/octopus-deploy/templates/role.yaml @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: - app: {{ template "octopus.name" . }} - chart: {{ template "octopus.chart" . }} - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} + {{- include "labels" . | nindent 4 }} name: {{ template "octopus.fullname" . }} rules: {{ toYaml .Values.octopus.rbac.role.rules }} diff --git a/charts/octopus-deploy/templates/rolebinding.yml b/charts/octopus-deploy/templates/rolebinding.yml index add25c8e..275d6e10 100644 --- a/charts/octopus-deploy/templates/rolebinding.yml +++ b/charts/octopus-deploy/templates/rolebinding.yml @@ -3,10 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: - app: {{ template "octopus.name" . }} - chart: {{ template "octopus.chart" . }} - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} + {{- include "labels" . | nindent 4 }} name: {{ template "octopus.fullname" . }} subjects: - kind: ServiceAccount diff --git a/charts/octopus-deploy/templates/serviceaccount.yaml b/charts/octopus-deploy/templates/serviceaccount.yaml index 963cb21b..b51a1324 100644 --- a/charts/octopus-deploy/templates/serviceaccount.yaml +++ b/charts/octopus-deploy/templates/serviceaccount.yaml @@ -7,10 +7,7 @@ metadata: {{ tpl (toYaml .) $ | indent 4 }} {{- end }} labels: - app: {{ template "octopus.name" . }} - chart: {{ template "octopus.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "labels" . | nindent 4 }} {{- if .Values.octopus.serviceAccount.labels }} {{ toYaml .Values.octopus.serviceAccount.labels | indent 2 }} {{- end }}