Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ k8s_yaml(helm('./helm/bundles/cortex-crds', name='cortex-crds', set=crd_extra_va
if 'nova' in ACTIVE_DEPLOYMENTS:
print("Activating Cortex Nova bundle")
k8s_yaml(helm('./helm/bundles/cortex-nova', name='cortex-nova', values=tilt_values, set=env_set_overrides))
k8s_resource('cortex-nova-postgresql-v18', labels=['Cortex-Nova'], port_forwards=[
k8s_resource('cortex-nova-postgresql-v18-g0', labels=['Cortex-Nova'], port_forwards=[
port_forward(8000, 5432),
])
k8s_resource('cortex-nova-scheduling-controller-manager', labels=['Cortex-Nova'], port_forwards=[
Expand All @@ -221,7 +221,7 @@ if 'nova' in ACTIVE_DEPLOYMENTS:
if 'manila' in ACTIVE_DEPLOYMENTS:
print("Activating Cortex Manila bundle")
k8s_yaml(helm('./helm/bundles/cortex-manila', name='cortex-manila', values=tilt_values, set=env_set_overrides))
k8s_resource('cortex-manila-postgresql-v18', labels=['Cortex-Manila'], port_forwards=[
k8s_resource('cortex-manila-postgresql-v18-g0', labels=['Cortex-Manila'], port_forwards=[
port_forward(8002, 5432),
])
k8s_resource('cortex-manila-scheduling-controller-manager', labels=['Cortex-Manila'], port_forwards=[
Expand All @@ -238,7 +238,7 @@ if 'manila' in ACTIVE_DEPLOYMENTS:

if 'cinder' in ACTIVE_DEPLOYMENTS:
k8s_yaml(helm('./helm/bundles/cortex-cinder', name='cortex-cinder', values=tilt_values, set=env_set_overrides))
k8s_resource('cortex-cinder-postgresql-v18', labels=['Cortex-Cinder'], port_forwards=[
k8s_resource('cortex-cinder-postgresql-v18-g0', labels=['Cortex-Cinder'], port_forwards=[
port_forward(8004, 5432),
])
k8s_resource('cortex-cinder-scheduling-controller-manager', labels=['Cortex-Cinder'], port_forwards=[
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-cinder/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Secret
metadata:
name: cortex-cinder-postgres
data:
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
user: {{ .Values.postgres.user | b64enc | quote }}
password: {{ .Values.postgres.password | b64enc | quote }}
database: {{ .Values.postgres.database | b64enc | quote }}
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-cinder/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sharedSSOCert: &sharedSSOCert
selfSigned: "false"

postgres:
host: cortex-cinder-postgresql-v18
host: cortex-cinder-postgresql-v18-g0
Comment thread
umswmayj marked this conversation as resolved.
user: postgres
password: secret
database: postgres
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-manila/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Secret
metadata:
name: cortex-manila-postgres
data:
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
user: {{ .Values.postgres.user | b64enc | quote }}
password: {{ .Values.postgres.password | b64enc | quote }}
database: {{ .Values.postgres.database | b64enc | quote }}
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-manila/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sharedSSOCert: &sharedSSOCert
selfSigned: "false"

postgres:
host: cortex-manila-postgresql-v18
host: cortex-manila-postgresql-v18-g0
user: postgres
password: secret
database: postgres
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-nova/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Secret
metadata:
name: cortex-nova-postgres
data:
host: {{ printf "%s-v%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") | b64enc | quote }}
host: {{ printf "%s-v%s-%s" (index .Values "cortex-postgres" "fullnameOverride") (index .Values "cortex-postgres" "major") (index .Values "cortex-postgres" "instanceSuffix") | b64enc | quote }}
user: {{ .Values.postgres.user | b64enc | quote }}
password: {{ .Values.postgres.password | b64enc | quote }}
database: {{ .Values.postgres.database | b64enc | quote }}
Expand Down
2 changes: 1 addition & 1 deletion helm/bundles/cortex-nova/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sharedSSOCert: &sharedSSOCert
selfSigned: "false"

postgres:
host: cortex-nova-postgresql-v18
host: cortex-nova-postgresql-v18-g0
user: postgres
password: secret
database: postgres
Expand Down
6 changes: 4 additions & 2 deletions helm/library/cortex-postgres/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ Create the name of the service account to use
{{- end }}

{{/*
Versioned fully qualified app name (appends -v<major> to the fullname).
Versioned fully qualified app name (appends -v<major>-<instanceSuffix> to the fullname).
The instanceSuffix is a rotation token: bumping it forces a new StatefulSet and PVC
to be provisioned, which re-runs initdb with the (rotated) POSTGRES_PASSWORD.
Truncates the base name to leave room for the suffix within the 63-char DNS limit.
*/}}
{{- define "cortex-postgres.versionedFullname" -}}
{{- $suffix := printf "-v%s" .Values.major -}}
{{- $suffix := printf "-v%s-%s" .Values.major .Values.instanceSuffix -}}
{{- $base := include "cortex-postgres.fullname" . -}}
{{- printf "%s%s" ($base | trunc (int (sub 63 (len $suffix)))) $suffix | trimSuffix "-" }}
{{- end }}
1 change: 1 addition & 0 deletions helm/library/cortex-postgres/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ spec:
selector:
{{- include "cortex-postgres.selectorLabels" . | nindent 4 }}
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}
2 changes: 2 additions & 0 deletions helm/library/cortex-postgres/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ spec:
matchLabels:
{{- include "cortex-postgres.selectorLabels" . | nindent 6 }}
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}
serviceName: {{ include "cortex-postgres.versionedFullname" . }}
template:
metadata:
labels:
app: {{ include "cortex-postgres.versionedFullname" . }}
{{- include "cortex-postgres.labels" . | nindent 8 }}
app.kubernetes.io/pg-major: {{ .Values.major | quote }}
app.kubernetes.io/instance-suffix: {{ .Values.instanceSuffix | quote }}
spec:
terminationGracePeriodSeconds: 10
containers:
Expand Down
7 changes: 7 additions & 0 deletions helm/library/cortex-postgres/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ fullnameOverride: cortex-postgresql

major: "18"

# Rotation token (generation). Bump to g1, g2, ... to provision a fresh
# StatefulSet + PVC, which causes initdb to run again and apply the (rotated)
# POSTGRES_PASSWORD from vault. The "g" prefix keeps the suffix visually
# distinct from the trailing StatefulSet pod ordinal (e.g. -g0-0 vs -0-0).
# The Postgres major version is independent and lives in `major` above.
instanceSuffix: "g0"

image:
repository: ghcr.io/cobaltcore-dev/cortex-postgres
pullPolicy: IfNotPresent
Expand Down