CoursesHelmIntermediate

Subcharts & dependencies

Compose charts; share values.

Intermediate12 min · lesson 7 of 12

A chart can depend on other charts — subcharts — declared in Chart.yaml. Installing an app that needs Postgres and Redis can pull in their charts as dependencies rather than you re-templating a database. You list dependencies with a name, version, and repository, then helm dependency update fetches them into charts/. This is how big applications are assembled from reusable pieces.

ASSEMBLING A CHART FROM SUBCHARTS
1Declare in Chart.yaml
name, version, repository, condition
2helm dependency update
fetch subcharts into charts/
3Configure via parent values
keyed by subchart name; global shared across all
4helm install
deploys parent + subchart workloads together
Pin subchart versions and commit Chart.lock so helm dependency build reproduces the same set; condition toggles a dependency on/off.
Chart.yaml
dependencies:
- name: postgresql
version: "15.5.x"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled # toggle the subchart on/off
- name: redis
version: "19.x.x"
repository: https://charts.bitnami.com/bitnami
# helm dependency update -> fetches these into charts/

Passing values to subcharts

Parent values reach a subchart under a key matching the subchart name, so postgresql: { auth: { database: payments } } in the parent’s values configures the postgresql subchart. A condition (postgresql.enabled) lets consumers turn a dependency off — deploy with the bundled database in dev, disable it and point at a managed database in prod. global values are shared across all subcharts for things like a common image registry.

parent values.yaml
postgresql:
enabled: true
auth:
database: payments
existingSecret: pg-credentials # subchart config, keyed by subchart name
global:
imageRegistry: registry.internal # shared with every subchart
A subchart is a dependency that deploys real workloads — pin and vet it
Subcharts (especially community database charts) run their own templates and workloads with your credentials, so pin them to exact versions in Chart.yaml, review what they deploy, and keep Chart.lock committed so helm dependency build reproduces the same set. An unpinned subchart pulls whatever the repo serves today — the same supply-chain risk as any unpinned dependency, deploying into your cluster.