Working with Subcharts
1. Adding Subcharts to Chart
| Method | Steps |
| Declared dependency | Add to Chart.yaml + helm dependency update |
| Vendored | Place chart directory directly under charts/ |
2. Declaring Subchart Dependencies
Example: Multiple subcharts
dependencies:
- name: postgresql
version: "15.3.0"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis
version: "19.0.0"
repository: https://charts.bitnami.com/bitnami
alias: cache
3. Overriding Subchart Values
Example: Override under subchart key
# Parent values.yaml
postgresql: # must match subchart name (or alias)
auth:
username: api
database: api_db
primary:
persistence:
size: 20Gi
cache: # uses alias
master:
persistence:
size: 5Gi
4. Using Global Values
Example: Shared global block
# Parent values.yaml
global:
imageRegistry: ghcr.io
storageClass: fast-ssd
# Available as .Values.global.* in EVERY subchart automatically
5. Importing Subchart Values
Example: Surface subchart exports
dependencies:
- name: postgresql
version: "15.3.0"
repository: https://charts.bitnami.com/bitnami
import-values:
- child: auth.username
parent: db.user
- exports.commonLabels # short form (reads under exports:)
6. Conditionally Enabling Subcharts
| Field | Usage |
condition: postgresql.enabled | Single boolean |
condition: a.enabled,b.enabled | First found is used |
Example: Group enable/disable
dependencies:
- { name: postgresql, version: "15.3.0", repository: ..., tags: [stateful] }
- { name: redis, version: "19.0.0", repository: ..., tags: [stateful, cache] }
# values.yaml
tags:
stateful: false # disables both subcharts
8. Accessing Parent Values
Note: Subcharts CANNOT read parent values directly. Use global for shared config or import-values to pull data upward, not downward.
9. Sharing Templates Across Charts
| Approach | How |
| Library chart | Set type: library; add as dependency; use include |
| Common helpers | Define helpers in parent's _helpers.tpl |
10. Managing Subchart Versions
| Practice | Reason |
| Pin exact versions | Reproducible deployments |
Commit Chart.lock | Lock-file-driven CI builds |
| Test subchart upgrades | Run in staging before bumping parent |