Skip to content

Commit c0bf587

Browse files
committed
fix(helm): prevent realtime envDefaults from masking app.env Secret values; add StatefulSet upgrade NOTES
- Realtime override-skip now considers keys set in either app.env or realtime.env. The shared app Secret is mounted via envFrom on the realtime pod, so a key set in app.env (e.g. NEXT_PUBLIC_APP_URL) would previously be masked by the realtime envDefault (inline env overrides envFrom in K8s). - NOTES.txt now prints a StatefulSet orphan-delete reminder on upgrade, surfacing the immutable serviceName issue documented in the README.
1 parent 3340872 commit c0bf587

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

helm/sim/templates/NOTES.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,27 @@ Your release is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}.
7878
# Upgrade after changing values
7979
helm upgrade {{ .Release.Name }} ./helm/sim --namespace {{ .Release.Namespace }} -f your-values.yaml
8080

81+
{{- if .Release.IsUpgrade }}
82+
5. Upgrading from a pre-1.0.0 build?
83+
84+
The internal Postgres StatefulSet's `spec.serviceName` was renamed to point
85+
at a new headless Service. That field is immutable, so `helm upgrade` will
86+
fail with: `Forbidden: updates to statefulset spec for fields other than
87+
...`. Orphan-delete the StatefulSet first (preserves pods and PVCs, traffic
88+
keeps flowing):
89+
90+
kubectl --namespace {{ .Release.Namespace }} delete statefulset {{ include "sim.fullname" . }}-postgresql --cascade=orphan
91+
{{- if .Values.copilot.enabled }}
92+
kubectl --namespace {{ .Release.Namespace }} delete statefulset {{ include "sim.fullname" . }}-copilot-postgresql --cascade=orphan
93+
{{- end }}
94+
95+
Then re-run `helm upgrade`. See README → "Upgrading from a pre-1.0.0 build"
96+
for the full procedure. Skip this step if you're already on 1.0.0+.
97+
98+
6. Where to go next:
99+
{{- else }}
81100
5. Where to go next:
101+
{{- end }}
82102

83103
* Production checklist: helm/sim/README.md (search "Production checklist")
84104
* Troubleshooting: helm/sim/README.md (search "Troubleshooting")

helm/sim/templates/deployment-realtime.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,20 @@ spec:
6767
{{- end }}
6868
{{- /*
6969
Inline realtime.envDefaults, skipping keys explicitly set in realtime.env
70-
(K8s `env` overrides `envFrom`, so an inline default would otherwise mask
71-
a user's Secret-bound value).
70+
OR app.env (K8s `env` overrides `envFrom`, so an inline default would
71+
otherwise mask a Secret-bound value). The chart-managed Secret is shared
72+
between app and realtime via envFrom, so a key set in app.env (e.g.
73+
NEXT_PUBLIC_APP_URL=https://prod.example.com) lands on the realtime pod
74+
too — inlining the localhost envDefault here would mask it.
7275
*/}}
7376
{{- $rtEnv := .Values.realtime.env | default dict }}
77+
{{- $appEnv := .Values.app.env | default dict }}
7478
{{- range $key, $value := .Values.realtime.envDefaults | default dict }}
75-
{{- $override := index $rtEnv $key }}
76-
{{- if and (ne (toString $value) "") (ne (toString $value) "<nil>") (or (not $override) (eq (toString $override) "") (eq (toString $override) "<nil>")) }}
79+
{{- $rtOverride := index $rtEnv $key }}
80+
{{- $appOverride := index $appEnv $key }}
81+
{{- $hasRt := and $rtOverride (ne (toString $rtOverride) "") (ne (toString $rtOverride) "<nil>") }}
82+
{{- $hasApp := and $appOverride (ne (toString $appOverride) "") (ne (toString $appOverride) "<nil>") }}
83+
{{- if and (ne (toString $value) "") (ne (toString $value) "<nil>") (not $hasRt) (not $hasApp) }}
7784
- name: {{ $key }}
7885
value: {{ $value | quote }}
7986
{{- end }}

0 commit comments

Comments
 (0)