Day 9: Dependencies and Subcharts
Goal: Build your own subchart
postgres, include it as a dependency and use it to give the releasenotesa real database – including a migration in an init container. · Duration: approx. 60 min · Prerequisite: Day 8
Briefing
dependenciesinChart.yamlis the wish (a version range),Chart.lockthe decision (exact version + digest).dependency updateresolves,dependency buildbuilds exactly from the lock.- A subchart only sees its own section of the values, plus
global. - Parent chart and subchart end up in one release. Helm does not wait until the database is ready – the application has to cope with that.
- Deliberately no third-party PostgreSQL chart: a small subchart of your own shows every mechanism and brings no foreign images.
Release notes (ns notes)
├─ notes Deployment notes ── initContainer migrate ──┐
│ values: postgres.enabled, global.dbSecret │ NOTES_DB_URL
└─ charts/postgres StatefulSet notes-postgres + Service <────┘
Secret notes-db (kubectl) <── both read the password
Drill 1: The postgres subchart
The subchart is a perfectly normal chart next to notes
in the repo:
# on prod
mkdir -p ~/helm/tag09 && cd ~/helm/charts
mkdir -p postgres/templates
cat > postgres/Chart.yaml <<'EOF'
# postgres/Chart.yaml – Stand Tag 09
apiVersion: v2
name: postgres
description: Kleines PostgreSQL als StatefulSet – Subchart von notes
type: application
version: 0.1.0
appVersion: "18.7"
EOF
cat > postgres/values.yaml <<'EOF'
# postgres/values.yaml – Stand Tag 09
image:
repository: docker.io/library/postgres
tag: 18.7-alpine
auth:
# -- Benutzer und Datenbank, die beim ersten Start angelegt werden
username: notes
database: notes
# -- Secret mit dem Passwort (leer = global.dbSecret)
existingSecret: ""
passwordKey: password
# -- Größe des PVC
storage: 1Gi
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 256Mi
EOF
cat > postgres/templates/_helpers.tpl <<'EOF'
{{/* postgres/templates/_helpers.tpl – Stand Tag 09 */}}
{{- define "postgres.fullname" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "postgres.selectorLabels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "postgres.secret" -}}
{{- $g := .Values.global | default dict }}
{{- required "auth.existingSecret oder global.dbSecret fehlt"
(coalesce .Values.auth.existingSecret $g.dbSecret) }}
{{- end }}
EOF
cat > postgres/templates/service.yaml <<'EOF'
{{/* postgres/templates/service.yaml – Stand Tag 09 */}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "postgres.fullname" . }}
labels:
{{- include "postgres.selectorLabels" . | nindent 4 }}
spec:
selector:
{{- include "postgres.selectorLabels" . | nindent 4 }}
ports:
- name: postgres
port: 5432
targetPort: postgres
EOF
cat > postgres/templates/statefulset.yaml <<'EOF'
{{/* postgres/templates/statefulset.yaml – Stand Tag 09 */}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "postgres.fullname" . }}
labels:
{{- include "postgres.selectorLabels" . | nindent 4 }}
spec:
serviceName: {{ include "postgres.fullname" . }}
replicas: 1
selector:
matchLabels:
{{- include "postgres.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "postgres.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: postgres
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports: [{name: postgres, containerPort: 5432}]
env:
- name: POSTGRES_USER
value: {{ .Values.auth.username | quote }}
- name: POSTGRES_DB
value: {{ .Values.auth.database | quote }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "postgres.secret" . }}
key: {{ .Values.auth.passwordKey }}
readinessProbe:
exec:
command: ["pg_isready", "-U", "{{ .Values.auth.username }}"]
periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /var/lib/postgresql
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: {{ .Values.storage }}
EOF
helm lint postgres --set global.dbSecret=notes-db | tail -1
helm template db ./postgres --set global.dbSecret=notes-db \
| grep -E '^kind| name:|image:'
helm template db ./postgres 2>&1 | head -1Expected:
1 chart(s) linted, 0 chart(s) failed
kind: Service
name: db-postgres
kind: StatefulSet
name: db-postgres
image: "docker.io/library/postgres:18.7-alpine"
name: notes-db
name: data
Error: execution error at (postgres/templates/statefulset.yaml:31:27):
auth.existingSecret oder global.dbSecret fehlt
The German comments in values.yaml are the
# -- docs: user and database created on first start, the
Secret with the password (empty = global.dbSecret), and the
PVC size. The error
auth.existingSecret oder global.dbSecret fehlt means
‘auth.existingSecret or global.dbSecret is missing’.
PostgreSQL 18 stores its data under
/var/lib/postgresql/18/ – that is why the volume is mounted
one level higher than with older versions.
.Values.global | default dict protects the helper when the
chart is rendered on its own without global.
Save your progress? Sign up for free
Drill 2: Add the dependency
# on prod
cat >> notes/Chart.yaml <<'EOF'
dependencies:
- name: postgres
version: "~0.1.0"
repository: file://../postgres
condition: postgres.enabled
EOF
sed -i 's/^version: .*/version: 0.8.0/; s/Tag 08/Tag 09/' notes/Chart.yaml
helm dependency list notes
helm template notes ./notes -f values/prod.yaml 2>&1 | head -1
helm dependency update notes | tail -2
helm dependency list notes
ls notes/charts
cat notes/Chart.lockExpected (abridged):
NAME VERSION REPOSITORY STATUS
postgres ~0.1.0 file://../postgres missing
Error: an error occurred while checking for chart dependencies. You may need to run
'helm dependency build' to fetch missing dependencies: found in Chart.yaml, but missing
in charts/ directory: postgres
Saving 1 charts
Deleting outdated charts
NAME VERSION REPOSITORY STATUS
postgres ~0.1.0 file://../postgres ok
postgres-0.1.0.tgz
dependencies:
- name: postgres
repository: file://../postgres
version: 0.1.0
digest: sha256:fda9b095c5a6…
generated: "2026-11-20T01:39:47.628254779Z"
~0.1.0 means “0.1.x”. update packs the
subchart as a .tgz into notes/charts/ and
writes Chart.lock. Your .gitignore excludes
the .tgz; Chart.lock belongs in the repo.
Save your progress? Sign up for free
Drill 3: The schema trap
# on prod
helm template notes ./notes -f values/prod.yaml 2>&1 | grep -E '^- at'
jq '.title = "notes – Stand Tag 09"
| .properties.postgres = {"type": "object",
"properties": {"enabled": {"type": "boolean"}}}' \
notes/values.schema.json > /tmp/s.json && mv /tmp/s.json notes/values.schema.json
helm template notes ./notes -f values/prod.yaml 2>&1 | head -1
helm template notes ./notes -f values/prod.yaml --set global.dbSecret=notes-db 2>&1 \
| grep -E '^- at'
jq '.properties.global = {"type": "object"}' notes/values.schema.json > /tmp/s.json \
&& mv /tmp/s.json notes/values.schema.jsonExpected:
- at '': additional properties 'postgres' not allowed
Error: execution error at (notes/charts/postgres/templates/statefulset.yaml:31:27):
auth.existingSecret oder global.dbSecret fehlt
- at '': additional properties 'global' not allowed
Three lessons: Helm attaches the subchart’s values under
postgres to the parent values –
additionalProperties: false rejects them, even if you set
nothing yourself. global only shows up once someone sets
it. And without postgres.enabled in the values the
condition cannot be found, so the subchart is on. That
is why a clear default goes into values.yaml:
# on prod
cat >> notes/values.yaml <<'EOF'
# -- Werte, die alle Charts sehen (auch das Subchart postgres)
global:
# -- Secret mit dem DB-Passwort (Schlüssel password) für notes und postgres
dbSecret: ""
postgres:
# -- Eigenes PostgreSQL als Subchart mitliefern
enabled: false
EOF
sed -i 's/Stand Tag 08/Stand Tag 09/' notes/values.yaml
helm template notes ./notes -f values/prod.yaml | grep -c 'Source: notes/charts'Expected:
0
Save your progress? Sign up for free
Drill 4: Init container migrate
notes-api needs the table notes before it answers
requests. The subcommand migrate creates it (idempotently).
The init container and the main container need the same DB environment –
one helper in _helpers.tpl instead of duplicated YAML. It
derives the host from the subchart if none is set.
# on prod
cat >> notes/templates/_helpers.tpl <<'EOF'
{{/* DB-Umgebung für Init-Container und notes-api; leer = Speicherbetrieb */}}
{{- define "notes.dbEnv" -}}
{{- $db := .Values.database }}
{{- $secret := coalesce $db.existingSecret .Values.global.dbSecret }}
{{- if $secret }}
{{- $host := $db.host }}
{{- if and (not $host) .Values.postgres.enabled }}
{{- $host = printf "%s-postgres" .Release.Name }}
{{- end }}
- name: NOTES_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $secret }}
key: {{ $db.passwordKey }}
- name: NOTES_DB_URL
value: {{ printf "postgres://%s:$(NOTES_DB_PASSWORD)@%s:%v/%s?%s" $db.user
(required "database.host fehlt" $host) $db.port $db.name "sslmode=disable"
| quote }}
{{- end }}
{{- end }}
EOF
sed -i 's/Stand Tag 07/Stand Tag 09/' notes/templates/_helpers.tpl
cat > notes/templates/deployment.yaml <<'EOF'
{{/* notes/templates/deployment.yaml – Stand Tag 09 */}}
{{- $dbEnv := include "notes.dbEnv" . }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "notes.fullname" . }}
labels:
{{- include "notes.labels" . | nindent 4 }}
spec:
replicas: {{ hasKey .Values "replicaCount" | ternary .Values.replicaCount 2 }}
selector:
matchLabels:
{{- include "notes.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "notes.labels" . | nindent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") .
| sha256sum }}
spec:
terminationGracePeriodSeconds: {{ durationSeconds .Values.shutdownTimeout }}
{{- if $dbEnv }}
initContainers:
- name: migrate
image: {{ include "notes.image" . | quote }}
args: ["migrate"]
env:
{{- $dbEnv | nindent 12 }}
{{- end }}
containers:
- name: notes-api
image: {{ include "notes.image" . | quote }}
ports: [{name: http, containerPort: 8080}]
env:
- name: NOTES_API_KEY
valueFrom:
secretKeyRef:
name: {{ required "apiKey.existingSecret fehlt"
.Values.apiKey.existingSecret }}
key: {{ .Values.apiKey.key }}
{{- with $dbEnv }}
{{- . | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "notes.fullname" . }}-config
readinessProbe:
httpGet: {path: /healthz, port: http}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
EOF
helm template notes ./notes -f values/prod.yaml -s templates/deployment.yaml \
| grep -c NOTES_DB
helm template notes ./notes -f values/prod.yaml --set postgres.enabled=true \
--set global.dbSecret=notes-db | grep -E '^kind|value: "postgres'Expected (abridged):
0
kind: ConfigMap
kind: ConfigMap
kind: ConfigMap
kind: Service
kind: Service
kind: Deployment
value: "postgres://notes:$(NOTES_DB_PASSWORD)@notes-postgres:5432/notes?…
value: "postgres://notes:$(NOTES_DB_PASSWORD)@notes-postgres:5432/notes?…
kind: StatefulSet
kind: Ingress
Without a Secret everything stays as it was yesterday (in-memory mode, no init container). With a Secret and the subchart, you get a StatefulSet, a Service, the init container and the URL twice on top.
Save your progress? Sign up for free
Drill 5: Helm does not wait for the database
Now the release notes gets its database – on purpose
without --wait, so you can watch:
# on prod
kubectl -n notes create secret generic notes-db --from-literal=password=lab-db-123
cat >> values/prod.yaml <<'EOF'
global:
dbSecret: notes-db
postgres:
enabled: true
EOF
sed -i 's/Stand Tag 08/Stand Tag 09/' values/prod.yaml
helm upgrade notes ./notes -n notes -f values/prod.yaml | grep -E 'REVISION|STATUS'
for i in 1 2 3 4 5 6; do sleep 5; kubectl -n notes get pods --no-headers; doneExpected (abridged):
secret/notes-db created
STATUS: deployed
REVISION: 20
notes-55cbbc96cf-7nrnh 1/1 Running 0 4m18s
notes-55cbbc96cf-hwxrw 1/1 Running 0 4m17s
notes-57d48b9df5-ptp6j 0/1 Init:Error 1 (4s ago) 6s
notes-postgres-0 0/1 ContainerCreating 0 6s
...
notes-57d48b9df5-ptp6j 0/1 Init:0/1 2 (15s ago) 17s
notes-postgres-0 0/1 ContainerCreating 0 17s
...
notes-57d48b9df5-ptp6j 0/1 Init:Error 2 (31s ago) 33s
notes-postgres-0 0/1 Running 0 33s
Helm reports deployed while the init container is still
failing: Postgres is pulling its image and initialising. Kubernetes
restarts migrate with growing back-off, and the old Pods
keep running in the meantime. One minute later:
# on prod
kubectl -n notes get pods
kubectl -n notes logs deploy/notes -c migrate --tail 1
curl -s -w ' %{http_code}\n' -H 'Host: api.notes.lab' -H 'X-API-Key: lab-key-123' \
localhost/notes -d '{"text":"in Postgres"}'
for i in 1 2 3; do curl -s -H 'Host: api.notes.lab' localhost/notes; echo; done
kubectl -n notes exec notes-postgres-0 -- \
psql -U notes -tAc 'select count(*) from notes'Expected (abridged):
NAME READY STATUS RESTARTS AGE
notes-57d48b9df5-fbdxz 1/1 Running 0 37s
notes-57d48b9df5-ptp6j 1/1 Running 0 80s
notes-postgres-0 1/1 Running 0 80s
time=2026-11-20T01:41:12.515Z level=INFO msg="migration complete" table=notes
{"id":"e725da85-…","text":"in Postgres"} 201
[{"id":"e725da85-…","text":"in Postgres"}]
[{"id":"e725da85-…","text":"in Postgres"}]
[{"id":"e725da85-…","text":"in Postgres"}]
1
Both Pods now see the same note. Here, the init container restarts
are the mechanism that does the “waiting” – not Helm. With
--wait, Helm would only have waited until everything was
ready and reported failed on timeout (Day 13).
Save your progress? Sign up for free
Drill 6: What the subchart sees, import-values
Experiments with the dependency tree run in a copy of the whole repo:
# on prod
cd ~/helm/tag09 && rm -rf repo && cp -r ~/helm/charts repo && cd repo
cat > postgres/templates/sicht.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: sicht
data:
storage: {{ .Values.storage | quote }}
global: {{ .Values.global | toJson | quote }}
elternTeam: {{ .Values.team | quote }}
schluessel: {{ keys .Values | sortAlpha | join "," | quote }}
EOF
helm dependency update notes >/dev/null
helm template t ./notes --set apiKey.existingSecret=x --set global.dbSecret=s \
--set postgres.enabled=true --set team=plattform --set postgres.storage=2Gi \
-s charts/postgres/templates/sicht.yaml | sed -n '/^data/,$p'Expected:
data:
storage: "2Gi"
global: "{\"dbSecret\":\"s\"}"
elternTeam:
schluessel: "auth,enabled,global,image,resources,storage"
The parent’s postgres.storage becomes
.Values.storage in the subchart, the parent’s
team is invisible, global arrives. After
changing the subchart, always run dependency update first –
otherwise Helm renders the old .tgz. The opposite direction
is called import-values:
# on prod
rm postgres/templates/sicht.yaml
cat >> notes/Chart.yaml <<'EOF'
import-values:
- child: auth
parent: dbAuth
EOF
helm dependency update notes >/dev/null
jq 'del(.additionalProperties)' notes/values.schema.json > s.json
mv s.json notes/values.schema.json
cat > notes/templates/spielwiese.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: spiel
data:
importiert: {{ .Values.dbAuth.username | quote }}
direkt: {{ .Values.postgres.auth.username | quote }}
EOF
B='--set apiKey.existingSecret=x --set global.dbSecret=s --set postgres.enabled=true'
helm template t ./notes $B -s templates/spielwiese.yaml | sed -n '/^data/,$p'
helm template t ./notes $B --set postgres.auth.username=app \
-s templates/spielwiese.yaml | sed -n '/^data/,$p'
helm template t ./notes --set apiKey.existingSecret=x -s templates/spielwiese.yaml \
2>&1 | grep nilExpected:
data:
importiert: "notes"
direkt: "notes"
data:
importiert: "notes"
direkt: "app"
nil pointer evaluating interface {}.username
Two traps: import-values fetches the subchart’s
default values; an override via
postgres.auth.username does not arrive there. And if the
subchart is disabled, its values disappear entirely – including
.Values.postgres.auth.
Save your progress? Sign up for free
Drill 7: Chart.lock versus version range
# on prod
cd ~/helm/tag09 && rm -rf repo && cp -r ~/helm/charts repo && cd repo
sed -i 's/^version: 0.1.0/version: 0.1.1/' postgres/Chart.yaml
helm dependency build notes 2>&1 | tail -1
helm dependency list notes
helm dependency update notes >/dev/null
ls notes/charts; yq '.dependencies[0].version' notes/Chart.lock
sed -i 's/version: "~0.1.0"/version: "~0.2.0"/' notes/Chart.yaml
helm dependency build notes 2>&1 | tail -1Expected:
Error: can't get a valid version for dependency postgres
NAME VERSION REPOSITORY STATUS
postgres ~0.1.0 file://../postgres ok
postgres-0.1.1.tgz
0.1.1
Error: the lock file (Chart.lock) is out of sync with the dependencies file
(Chart.yaml). Please update the dependencies with 'helm dependency update'
build insists on the version from
Chart.lock (0.1.0). A file:// repo, however,
only offers what is currently in the folder – that is why
build fails. With a real chart repository (Day 15) it
delivers exactly the locked version. dependency list still
reports ok: it only checks whether the .tgz
matches the range, not the lock. If Chart.yaml changes,
build refuses to work until someone runs
update.
Save your progress? Sign up for free
Drill 8: alias, tags and condition
The same subchart twice, switchable together via tags:
# on prod
cd ~/helm/tag09 && rm -rf repo && cp -r ~/helm/charts repo && cd repo
yq -i '.dependencies = [
{"name": "postgres", "alias": "db-a", "version": "~0.1.0",
"repository": "file://../postgres", "tags": ["datenbank"]},
{"name": "postgres", "alias": "db-b", "version": "~0.1.0",
"repository": "file://../postgres", "tags": ["datenbank"],
"condition": "db-b.enabled"}]' notes/Chart.yaml
jq 'del(.additionalProperties)' notes/values.schema.json > s.json
mv s.json notes/values.schema.json
helm dependency update notes >/dev/null
B='--set apiKey.existingSecret=x --set global.dbSecret=s --set database.host=t-db-a'
helm template t ./notes $B --set db-b.storage=2Gi \
| grep -E '^# Source: notes/charts|^ name: t-db|storage: '
helm template t ./notes $B --set tags.datenbank=false | grep -c 'notes/charts'
helm template t ./notes $B --set tags.datenbank=false --set db-b.enabled=true \
| grep 'Source: notes/charts'Expected:
# Source: notes/charts/db-a/templates/service.yaml
name: t-db-a
# Source: notes/charts/db-b/templates/service.yaml
name: t-db-b
# Source: notes/charts/db-a/templates/statefulset.yaml
name: t-db-a
storage: 1Gi
# Source: notes/charts/db-b/templates/statefulset.yaml
name: t-db-b
storage: 2Gi
0
# Source: notes/charts/db-b/templates/service.yaml
# Source: notes/charts/db-b/templates/statefulset.yaml
With alias, the subchart’s template sees
.Chart.Name = db-a – that is why it gets its own names, and
the values live under db-a/db-b.
tags switch groups, a condition beats the tag:
db-b runs despite tags.datenbank=false.
Save your progress? Sign up for free
Exercise: Speed Drills
- Show the status of the dependencies of
notes. Target time: 15 s - Which subchart version is locked? Target time: 15 s
- Count the notes directly in Postgres. Target time: 30 s
- Render only the subchart’s StatefulSet with
prod.yaml, show image and size. Target time: 30 s
Solution
# on prod
cd ~/helm/charts
helm dependency list notes
yq '.dependencies[0].version' notes/Chart.lock
kubectl -n notes exec notes-postgres-0 -- \
psql -U notes -tAc 'select count(*) from notes'
helm template notes ./notes -f values/prod.yaml \
-s charts/postgres/templates/statefulset.yaml | grep -E 'image:|storage:'Expected:
NAME VERSION REPOSITORY STATUS
postgres ~0.1.0 file://../postgres ok
0.1.0
1
image: "docker.io/library/postgres:18.7-alpine"
storage: 1Gi
Save your progress? Sign up for free
Checkpoint
# on prod
helm list -n notesExpected: Revision 20, notes-0.8.0,
deployed.
# on prod
kubectl -n notes get deploy notes \
-o jsonpath='{.spec.template.spec.initContainers[0].args}{"\n"}'Expected: ["migrate"]
# on prod
kubectl -n notes get pvcExpected: data-notes-postgres-0 with
status Bound, 1Gi, local-path.
Challenge
In tag09, install a release zwei from a
copy that brings postgres twice (db-a,
db-b); notes-api uses db-a. Wait until
everything is ready, uninstall the release and check what is left.
Hint: A StatefulSet’s PVCs are created from
volumeClaimTemplates – not from the chart.
Solution
# on prod
cd ~/helm/tag09 && rm -rf repo && cp -r ~/helm/charts repo && cd repo
yq -i '.dependencies = [
{"name": "postgres", "alias": "db-a", "version": "~0.1.0",
"repository": "file://../postgres"},
{"name": "postgres", "alias": "db-b", "version": "~0.1.0",
"repository": "file://../postgres"}]' notes/Chart.yaml
jq '.properties["db-a"] = {"type": "object"}
| .properties["db-b"] = {"type": "object"}' \
notes/values.schema.json > s.json && mv s.json notes/values.schema.json
helm dependency update notes | tail -1
kubectl create namespace tag09
kubectl -n tag09 create secret generic notes-db --from-literal=password=lab-db-123
kubectl -n tag09 create secret generic notes-api-key --from-literal=api-key=lab-key-123
helm install zwei ./notes -n tag09 --set apiKey.existingSecret=notes-api-key \
--set global.dbSecret=notes-db --set database.host=zwei-db-a --set replicaCount=1 \
--wait --timeout 3m | grep STATUS
kubectl -n tag09 get statefulset,pvc
helm uninstall zwei -n tag09
kubectl -n tag09 get pvcExpected (abridged):
STATUS: deployed
NAME READY AGE
statefulset.apps/zwei-db-a 1/1 43s
statefulset.apps/zwei-db-b 1/1 43s
NAME STATUS ... CAPACITY ...
persistentvolumeclaim/data-zwei-db-a-0 Bound ... 1Gi ...
persistentvolumeclaim/data-zwei-db-b-0 Bound ... 1Gi ...
release "zwei" uninstalled
NAME STATUS ... CAPACITY ...
data-zwei-db-a-0 Bound ... 1Gi ...
data-zwei-db-b-0 Bound ... 1Gi ...
helm uninstall deletes what is in the manifest. The PVCs
were created by the StatefulSet controller, so they survive – good for
data, bad for throwaway environments. Anyone who reinstalls gets the old
data (and the old password) back.
Save your progress? Sign up for free
Cleanup
# on prod
kubectl delete namespace tag09
cd ~/helm/charts
git add -A
git commit -qm "Tag 09: Subchart postgres, global, Init-Container migrate, notes 0.8.0"Expected:
namespace "tag09" deleted
Interview Note
dependency updateorbuild?updateresolves the ranges again and writesChart.lock,buildfetches exactly the locked versions. Usebuildin CI so builds are reproducible.- How do you pass values to a subchart? Under its name (or
alias) in the parent values; whatever everyone needs goes under
global. That is all the subchart sees. - Does Helm wait until the database is ready? No. Parent chart and subchart are applied together. Init containers, retries in the app or hooks (Day 11) have to establish the order.
Enterprise Note
- For real databases, an operator (e.g. CloudNativePG) provides
backups, failover and upgrades; the app chart then only references its
Secret (the
existingSecretpattern from Day 8). - Subcharts from third-party repos always with an exact version and
Chart.lockin Git; thecharts/directory is created in CI viadependency build. - A schema with
additionalProperties: falsemust know every subchart name, every alias andglobal– otherwise the first update of a subchart breaks validation. - PVCs from
volumeClaimTemplatessurvivehelm uninstall. Cleanup belongs in the process for throwaway environments; deleting in production needs a deliberate approval.