Skip to content

Commit 46f856d

Browse files
authored
feat(cortex-postgres): add suffix gX to postgresql (#939)
1 parent 66c983c commit 46f856d

11 files changed

Lines changed: 23 additions & 11 deletions

File tree

Tiltfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ k8s_yaml(helm('./helm/bundles/cortex-crds', name='cortex-crds', set=crd_extra_va
196196
if 'nova' in ACTIVE_DEPLOYMENTS:
197197
print("Activating Cortex Nova bundle")
198198
k8s_yaml(helm('./helm/bundles/cortex-nova', name='cortex-nova', values=tilt_values, set=env_set_overrides))
199-
k8s_resource('cortex-nova-postgresql-v18', labels=['Cortex-Nova'], port_forwards=[
199+
k8s_resource('cortex-nova-postgresql-v18-g0', labels=['Cortex-Nova'], port_forwards=[
200200
port_forward(8000, 5432),
201201
])
202202
k8s_resource('cortex-nova-scheduling-controller-manager', labels=['Cortex-Nova'], port_forwards=[
@@ -221,7 +221,7 @@ if 'nova' in ACTIVE_DEPLOYMENTS:
221221
if 'manila' in ACTIVE_DEPLOYMENTS:
222222
print("Activating Cortex Manila bundle")
223223
k8s_yaml(helm('./helm/bundles/cortex-manila', name='cortex-manila', values=tilt_values, set=env_set_overrides))
224-
k8s_resource('cortex-manila-postgresql-v18', labels=['Cortex-Manila'], port_forwards=[
224+
k8s_resource('cortex-manila-postgresql-v18-g0', labels=['Cortex-Manila'], port_forwards=[
225225
port_forward(8002, 5432),
226226
])
227227
k8s_resource('cortex-manila-scheduling-controller-manager', labels=['Cortex-Manila'], port_forwards=[
@@ -238,7 +238,7 @@ if 'manila' in ACTIVE_DEPLOYMENTS:
238238

239239
if 'cinder' in ACTIVE_DEPLOYMENTS:
240240
k8s_yaml(helm('./helm/bundles/cortex-cinder', name='cortex-cinder', values=tilt_values, set=env_set_overrides))
241-
k8s_resource('cortex-cinder-postgresql-v18', labels=['Cortex-Cinder'], port_forwards=[
241+
k8s_resource('cortex-cinder-postgresql-v18-g0', labels=['Cortex-Cinder'], port_forwards=[
242242
port_forward(8004, 5432),
243243
])
244244
k8s_resource('cortex-cinder-scheduling-controller-manager', labels=['Cortex-Cinder'], port_forwards=[

helm/bundles/cortex-cinder/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: Secret
44
metadata:
55
name: cortex-cinder-postgres
66
data:
7-
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
7+
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
88
user: {{ .Values.postgres.user | b64enc | quote }}
99
password: {{ .Values.postgres.password | b64enc | quote }}
1010
database: {{ .Values.postgres.database | b64enc | quote }}

helm/bundles/cortex-cinder/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sharedSSOCert: &sharedSSOCert
3838
selfSigned: "false"
3939

4040
postgres:
41-
host: cortex-cinder-postgresql-v18
41+
host: cortex-cinder-postgresql-v18-g0
4242
user: postgres
4343
password: secret
4444
database: postgres

helm/bundles/cortex-manila/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: Secret
44
metadata:
55
name: cortex-manila-postgres
66
data:
7-
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
7+
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
88
user: {{ .Values.postgres.user | b64enc | quote }}
99
password: {{ .Values.postgres.password | b64enc | quote }}
1010
database: {{ .Values.postgres.database | b64enc | quote }}

helm/bundles/cortex-manila/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sharedSSOCert: &sharedSSOCert
3838
selfSigned: "false"
3939

4040
postgres:
41-
host: cortex-manila-postgresql-v18
41+
host: cortex-manila-postgresql-v18-g0
4242
user: postgres
4343
password: secret
4444
database: postgres

helm/bundles/cortex-nova/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: Secret
44
metadata:
55
name: cortex-nova-postgres
66
data:
7-
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
7+
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
88
user: {{ .Values.postgres.user | b64enc | quote }}
99
password: {{ .Values.postgres.password | b64enc | quote }}
1010
database: {{ .Values.postgres.database | b64enc | quote }}

helm/bundles/cortex-nova/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sharedSSOCert: &sharedSSOCert
4343
selfSigned: "false"
4444

4545
postgres:
46-
host: cortex-nova-postgresql-v18
46+
host: cortex-nova-postgresql-v18-g0
4747
user: postgres
4848
password: secret
4949
database: postgres

helm/library/cortex-postgres/templates/_helpers.tpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ Create the name of the service account to use
6565
{{- end }}
6666

6767
{{/*
68-
Versioned fully qualified app name (appends -v<major> to the fullname).
68+
Versioned fully qualified app name (appends -v<major>-<instanceSuffix> to the fullname).
69+
The instanceSuffix is a rotation token: bumping it forces a new StatefulSet and PVC
70+
to be provisioned, which re-runs initdb with the (rotated) POSTGRES_PASSWORD.
6971
Truncates the base name to leave room for the suffix within the 63-char DNS limit.
7072
*/}}
7173
{{- define "cortex-postgres.versionedFullname" -}}
72-
{{- $suffix := printf "-v%s" .Values.major -}}
74+
{{- $suffix := printf "-v%s-%s" .Values.major .Values.instanceSuffix -}}
7375
{{- $base := include "cortex-postgres.fullname" . -}}
7476
{{- printf "%s%s" ($base | trunc (int (sub 63 (len $suffix)))) $suffix | trimSuffix "-" }}
7577
{{- end }}

helm/library/cortex-postgres/templates/service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ spec:
1717
selector:
1818
{{- include "cortex-postgres.selectorLabels" . | nindent 4 }}
1919
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
20+
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}

helm/library/cortex-postgres/templates/statefulset.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ spec:
1313
matchLabels:
1414
{{- include "cortex-postgres.selectorLabels" . | nindent 6 }}
1515
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
16+
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}
1617
serviceName: {{ include "cortex-postgres.versionedFullname" . }}
1718
template:
1819
metadata:
1920
labels:
2021
app: {{ include "cortex-postgres.versionedFullname" . }}
2122
{{- include "cortex-postgres.labels" . | nindent 8 }}
2223
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
24+
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}
2325
spec:
2426
terminationGracePeriodSeconds: 10
2527
containers:

0 commit comments

Comments
 (0)