Chart Dependencies
A complete guide to Helm chart dependencies covering dependency management, subcharts, conditions, aliases, and best practices for managing complex Helm charts.
Helm charts can depend on other charts. Dependencies are defined in Chart.yaml and managed using Helm commands. This enables composition of complex applications from reusable components.
- Subcharts: Dependent charts that are included in the parent chart
- Dependency Management: Helm commands for adding, updating, and managing dependencies
- Conditions: Enable/disable subcharts based on values
- Aliases: Rename subcharts to avoid conflicts
Dependencies are defined in the dependencies field of Chart.yaml.
# Chart.yaml with dependencies
apiVersion: v2
name: my-app
description: A Helm chart for my application
type: application
version: 1.0.0
appVersion: 1.0.0
dependencies:
# Simple dependency
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
# Dependency with condition
- name: redis
version: 16.x.x
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
# Dependency with alias
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
alias: analytics-db
condition: analytics-db.enabled
# Dependency from local path
- name: local-chart
version: 1.0.0
repository: file://../local-chart
# Dependency with tags
- name: mongodb
version: 12.x.x
repository: https://charts.bitnami.com/bitnami
tags:
- backend
- database
name
version
repository
condition
alias
tags
11.x.x or ^11.0.0 to allow patch updates while preventing breaking changes.
# Update dependencies (download charts)
helm dependency update
# Build dependencies (for local development)
helm dependency build
# List dependencies
helm dependency list
# Update a specific dependency
helm dependency update --skip-refresh
# Download dependencies without installing
helm dependency update --dry-run
# Example workflow
# 1. Add dependency to Chart.yaml
# 2. Run helm dependency update
# 3. The charts/ directory will contain the downloaded subcharts
# View dependency tree
helm dependency list my-chart/
# Check for outdated dependencies
helm dependency list my-chart/ --outdated
helm dependency update- Downloads dependencies tocharts/directoryhelm dependency build- Builds dependencies fromChart.lockhelm dependency list- Lists all dependencies and their status
Conditions allow you to enable or disable subcharts based on values, providing flexibility for different environments.
# Chart.yaml with condition
dependencies:
- name: redis
version: 16.x.x
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
condition: database.postgresql.enabled
# values.yaml
redis:
enabled: true # Enable Redis
database:
postgresql:
enabled: false # Disable PostgreSQL
# Condition with nested values
dependencies:
- name: mongodb
version: 12.x.x
repository: https://charts.bitnami.com/bitnami
condition: backend.database.enabled
# values.yaml
backend:
database:
enabled: true
# Multiple conditions (AND logic)
# Both conditions must be true
dependencies:
- name: elasticsearch
version: 19.x.x
repository: https://charts.bitnami.com/bitnami
condition: logging.enabled,elasticsearch.enabled
- Use meaningful condition paths (e.g.,
service.database.enabled) - Set sensible defaults in values.yaml
- Use conditions for optional dependencies
- Document all available conditions
- Use tags for grouping related dependencies
Aliases allow you to use the same chart multiple times with different names, avoiding conflicts and enabling multiple instances.
# Chart.yaml with aliases
dependencies:
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
alias: primary-db
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
alias: analytics-db
# values.yaml for aliases
primary-db:
postgresqlDatabase: primary
postgresqlUsername: primary_user
postgresqlPassword: primary_pass
analytics-db:
postgresqlDatabase: analytics
postgresqlUsername: analytics_user
postgresqlPassword: analytics_pass
# Accessing values in templates
# Use the alias name to reference the subchart
{{ .Values.primary-db.postgresqlDatabase }}
{{ .Values.analytics-db.postgresqlDatabase }}
# Example with Redis aliases
dependencies:
- name: redis
version: 16.x.x
repository: https://charts.bitnami.com/bitnami
alias: cache-redis
- name: redis
version: 16.x.x
repository: https://charts.bitnami.com/bitnami
alias: session-redis
# values.yaml
cache-redis:
redisPassword: cache-pass
redisPort: 6379
session-redis:
redisPassword: session-pass
redisPort: 6380
- Aliases are useful for running multiple instances of the same chart
- Each alias creates a separate release of the subchart
- Aliases can cause resource duplication (use with caution)
- Alias names must be unique within the chart
- Use meaningful alias names that describe the purpose
Values for subcharts are passed from the parent chart's values.yaml. You can override subchart values at the parent level.
# Parent chart values.yaml
# Override subchart values
postgresql:
postgresqlDatabase: myapp
postgresqlUsername: myapp_user
postgresqlPassword: myapp_pass
persistence:
enabled: true
size: 10Gi
redis:
redisPassword: redis_pass
master:
persistence:
enabled: true
# Using global values
global:
storageClass: standard
imagePullSecrets:
- name: regcred
# Subchart uses global values
# postgresql/values.yaml
global:
storageClass: standard
persistence:
storageClass: {{ .Values.global.storageClass }}
# Access subchart values in parent templates
# {{ .Values.postgresql.postgresqlDatabase }}
# Override subchart values during installation
helm install my-app ./my-app \
--set postgresql.postgresqlPassword=secret \
--set redis.redisPassword=secret
- Use
globalvalues for shared configuration - Override subchart values in parent values.yaml
- Document all overridden values
- Use
helm dependency updateto sync subchart values - Test subchart integration thoroughly
Database as a Service
Message Queue
Monitoring Stack
Logging Stack
# Common pattern: Database + Cache
dependencies:
- name: postgresql
version: 11.x.x
repository: https://charts.bitnami.com/bitnami
condition: database.postgresql.enabled
alias: db
- name: redis
version: 16.x.x
repository: https://charts.bitnami.com/bitnami
condition: cache.redis.enabled
alias: cache
# values.yaml
database:
postgresql:
enabled: true
postgresqlDatabase: myapp
postgresqlUsername: myapp_user
cache:
redis:
enabled: true
redisPassword: redis_pass
dependencies field in Chart.yaml, then run helm dependency update to download the chart.--set during installation for runtime overrides.repository: file://../path/to/chart in the dependency definition. This is useful for development and testing.helm upgrade with --set or a new values file. Subchart values are updated as part of the parent chart upgrade.Understanding chart dependencies is essential for building complex, reusable Helm charts. Master dependency management to compose applications from reusable components efficiently.