From 4310b807991e6d4191d9d5f656f1f9a83dfd31b7 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Tue, 24 Sep 2024 13:32:23 -0700 Subject: [PATCH] feat(template): add major version suffix to deployment names Signed-off-by: Thuan Vo --- charts/cryostat/templates/_helpers.tpl | 8 ++++++++ charts/cryostat/templates/cryostat_deployment.yaml | 2 +- charts/cryostat/templates/db_deployment.yaml | 2 +- charts/cryostat/templates/reports_deployment.yaml | 2 +- charts/cryostat/templates/storage_deployment.yaml | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/charts/cryostat/templates/_helpers.tpl b/charts/cryostat/templates/_helpers.tpl index c5acd82a..c68af86a 100644 --- a/charts/cryostat/templates/_helpers.tpl +++ b/charts/cryostat/templates/_helpers.tpl @@ -145,3 +145,11 @@ Get or generate a default secret key for auth proxy cookies. {{- end -}} {{- join "," (default list $l | compact | uniq) | quote -}} {{- end -}} + +{{/* +Get the name for managed deployments. +*/}} +{{- define "cryostat.deploymentName" -}} +{{- $version := semver .Chart.AppVersion -}} +{{- printf "%s-v%d" (include "cryostat.fullname" .) $version.Major -}} +{{- end -}} diff --git a/charts/cryostat/templates/cryostat_deployment.yaml b/charts/cryostat/templates/cryostat_deployment.yaml index 66ed91fd..6d836f9b 100644 --- a/charts/cryostat/templates/cryostat_deployment.yaml +++ b/charts/cryostat/templates/cryostat_deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "cryostat.fullname" . }} + name: {{ include "cryostat.deploymentName" . }} labels: {{- include "cryostat.labels" . | nindent 4 }} app.kubernetes.io/component: cryostat diff --git a/charts/cryostat/templates/db_deployment.yaml b/charts/cryostat/templates/db_deployment.yaml index f1891318..c6c753fd 100644 --- a/charts/cryostat/templates/db_deployment.yaml +++ b/charts/cryostat/templates/db_deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "cryostat.fullname" . }}-db + name: {{ include "cryostat.deploymentName" . }}-db labels: {{- include "cryostat.labels" . | nindent 4 }} app.kubernetes.io/component: db diff --git a/charts/cryostat/templates/reports_deployment.yaml b/charts/cryostat/templates/reports_deployment.yaml index c5b9b3d6..81507d0b 100644 --- a/charts/cryostat/templates/reports_deployment.yaml +++ b/charts/cryostat/templates/reports_deployment.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "cryostat.fullname" . }}-reports + name: {{ include "cryostat.deploymentName" . }}-reports labels: {{- include "cryostat.labels" . | nindent 4 }} app.kubernetes.io/component: reports diff --git a/charts/cryostat/templates/storage_deployment.yaml b/charts/cryostat/templates/storage_deployment.yaml index 6155450e..1525cb48 100644 --- a/charts/cryostat/templates/storage_deployment.yaml +++ b/charts/cryostat/templates/storage_deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "cryostat.fullname" . }}-storage + name: {{ include "cryostat.deploymentName" . }}-storage labels: {{- include "cryostat.labels" . | nindent 4 }} app.kubernetes.io/component: storage