Skip to content

Commit

Permalink
feat(template): add major version suffix to deployment names (#202)
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <[email protected]>
  • Loading branch information
tthvo authored Sep 25, 2024
1 parent 12879aa commit ddf87d5
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions charts/cryostat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion charts/cryostat/templates/cryostat_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/templates/db_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/templates/reports_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/templates/storage_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/tests/cryostat_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/tests/db_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/tests/reports_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/cryostat/tests/storage_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ddf87d5

Please sign in to comment.