Chart Dependencies
What you'll learn: How to declare and manage Helm chart dependencies to build modular, reusable chart architectures.
Why Chart Dependencies Matter
Imagine building a web application that needs a database and a cache. Instead of bundling PostgreSQL and Redis configurations directly into your app chart, you can declare them as dependencies—reusing existing, well-maintained charts. This keeps your chart focused, maintainable, and upgradeable.
How Dependencies Work
Chart dependencies establish parent-child relationships. Your chart (the parent) can depend on one or more other charts (children/sub-charts). Dependencies are declared in your chart's Chart.yaml file:
# Chart.yaml
apiVersion: v2
name: my-webapp
version: 1.0.0
dependencies:
- name: postgresql
version: "12.1.5"
repository: https://charts.bitnami.com/bitnami
- name: redis
version: "17.3.7"
repository: https://charts.bitnami.com/bitnami
After declaring dependencies, run helm dependency update to download them into your chart's charts/ directory. When you install the parent chart, Helm automatically installs all dependencies together.
Managing Dependency Behavior
You can customize how dependencies behave:
- Conditional dependencies: Use
conditionto enable/disable dependencies via values - Version constraints: Specify ranges like
version: "~12.1.0"for flexibility - Override values: Pass configuration to child charts through your parent
values.yaml
Dependencies are installed in the same namespace as the parent, and their lifecycle is tied together—uninstalling the parent removes all children.
Relationship Dynamics
The parent chart can override child chart values, but children remain independently templated. This separation keeps concerns clean while allowing top-level control.
Key Takeaway: Chart dependencies let you compose complex applications from smaller, reusable charts by declaring relationships in Chart.yaml, promoting modularity and maintainability in your Helm packages.