Chart Dependencies

A complete guide to Helm chart dependencies covering dependency management, subcharts, conditions, aliases, and best practices for managing complex Helm charts.

Dependencies Subcharts Conditions Aliases
Understanding Chart Dependencies

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
Key Concept: Dependencies allow you to reuse existing charts and compose complex applications. For example, an application chart can depend on PostgreSQL and Redis charts.
Defining Dependencies in Chart.yaml

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

The name of the dependency chart.

version

The version constraint for the dependency.

repository

The repository URL where the chart is stored.

condition

A path to a boolean value that enables/disables the dependency.

alias

An alias for the dependency to avoid name conflicts.

tags

Tags for grouping dependencies (used with tag conditions).
Version Constraints: Use semantic versioning constraints like 11.x.x or ^11.0.0 to allow patch updates while preventing breaking changes.
Dependency Management Commands
# 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
Command Explanation:
  • helm dependency update - Downloads dependencies to charts/ directory
  • helm dependency build - Builds dependencies from Chart.lock
  • helm dependency list - Lists all dependencies and their status
Conditions: Enabling/Disabling Dependencies

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
Condition Best Practices:
  • 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: Avoiding Name Conflicts

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
Alias Considerations:
  • 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
Subchart Values and Overrides

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
Subchart Value Best Practices:
  • Use global values for shared configuration
  • Override subchart values in parent values.yaml
  • Document all overridden values
  • Use helm dependency update to sync subchart values
  • Test subchart integration thoroughly
Common Dependency Patterns

Database as a Service

Include PostgreSQL, MySQL, or MongoDB as dependencies. Use conditions to enable/disable based on environment.

Message Queue

Include Redis, RabbitMQ, or Kafka as dependencies. Use aliases for multiple instances.

Monitoring Stack

Include Prometheus, Grafana, and AlertManager as optional dependencies. Use conditions to enable monitoring.

Logging Stack

Include Elasticsearch, Fluentd, and Kibana (EFK) as dependencies. Use tags for grouping.
# 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
Frequently Asked Questions
What is a subchart in Helm?
A subchart is a dependency chart that is included in a parent chart. Subcharts are managed using the dependencies field in Chart.yaml and are stored in the charts/ directory.
How do I add a dependency to a chart?
Add the dependency to the dependencies field in Chart.yaml, then run helm dependency update to download the chart.
What is the difference between condition and tags?
Conditions are evaluated per dependency (boolean). Tags are evaluated globally (a list of tags that must be matched). Use conditions for simple enable/disable, tags for grouping related dependencies.
How do I override subchart values?
Override subchart values in the parent chart's values.yaml using the subchart name as the key. Use --set during installation for runtime overrides.
What is an alias in Helm dependencies?
An alias allows you to use the same chart multiple times with different names. This is useful for multiple instances of the same dependency (e.g., two PostgreSQL databases).
How do I handle circular dependencies?
Helm does not support circular dependencies. Review your chart structure and break the cycle by extracting shared logic into a separate chart.
Can I use local charts as dependencies?
Yes, use repository: file://../path/to/chart in the dependency definition. This is useful for development and testing.
How do I update subchart values after installation?
Use helm upgrade with --set or a new values file. Subchart values are updated as part of the parent chart upgrade.
Previous: Chart Structure Next: Chart Hooks

Understanding chart dependencies is essential for building complex, reusable Helm charts. Master dependency management to compose applications from reusable components efficiently.