From 4310b807991e6d4191d9d5f656f1f9a83dfd31b7 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Tue, 24 Sep 2024 13:32:23 -0700 Subject: [PATCH 1/2] 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 From 027c184e4a41adfc10fe79688b67bfeab6376519 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Tue, 24 Sep 2024 13:35:32 -0700 Subject: [PATCH 2/2] test: update unittests --- charts/cryostat/tests/cryostat_deployment_test.yaml | 2 +- charts/cryostat/tests/db_deployment_test.yaml | 2 +- charts/cryostat/tests/reports_deployment_test.yaml | 2 +- charts/cryostat/tests/storage_deployment_test.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index 33a9b00a..5e5097e4 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -10,7 +10,7 @@ tests: value: Deployment - equal: path: metadata.name - value: RELEASE-NAME-cryostat + value: RELEASE-NAME-cryostat-v4 - equal: path: spec.replicas value: 1 diff --git a/charts/cryostat/tests/db_deployment_test.yaml b/charts/cryostat/tests/db_deployment_test.yaml index 76b00365..092b33b5 100644 --- a/charts/cryostat/tests/db_deployment_test.yaml +++ b/charts/cryostat/tests/db_deployment_test.yaml @@ -10,7 +10,7 @@ tests: value: Deployment - equal: path: metadata.name - value: RELEASE-NAME-cryostat-db + value: RELEASE-NAME-cryostat-v4-db - equal: path: spec.replicas value: 1 diff --git a/charts/cryostat/tests/reports_deployment_test.yaml b/charts/cryostat/tests/reports_deployment_test.yaml index 9b48b3da..d504264c 100644 --- a/charts/cryostat/tests/reports_deployment_test.yaml +++ b/charts/cryostat/tests/reports_deployment_test.yaml @@ -18,7 +18,7 @@ tests: value: Deployment - equal: path: metadata.name - value: RELEASE-NAME-cryostat-reports + value: RELEASE-NAME-cryostat-v4-reports - equal: path: spec.replicas value: 2 diff --git a/charts/cryostat/tests/storage_deployment_test.yaml b/charts/cryostat/tests/storage_deployment_test.yaml index b30ad444..ae1a8421 100644 --- a/charts/cryostat/tests/storage_deployment_test.yaml +++ b/charts/cryostat/tests/storage_deployment_test.yaml @@ -10,7 +10,7 @@ tests: value: Deployment - equal: path: metadata.name - value: RELEASE-NAME-cryostat-storage + value: RELEASE-NAME-cryostat-v4-storage - equal: path: spec.replicas value: 1