Helm
Kubernetes
DevOps
Configuration
Dependencies

Helm Chart pass variable to dependency

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

To pass values to a Helm dependency chart, nest them under the dependency's name in your parent chart's values.yaml. If your parent chart depends on redis, put Redis-specific values under a redis: key. Helm merges these values into the dependency chart's own values during rendering. You can also use global: values that are shared across all charts, or import-values to pull specific values from a dependency into the parent.

Defining Dependencies

yaml
1# Chart.yaml (parent chart)
2apiVersion: v2
3name: my-app
4version: 1.0.0
5
6dependencies:
7  - name: redis
8    version: "17.x.x"
9    repository: "https://charts.bitnami.com/bitnami"
10  - name: postgresql
11    version: "12.x.x"
12    repository: "https://charts.bitnami.com/bitnami"
bash
# Download dependencies
helm dependency update
# Creates charts/ directory with redis and postgresql tarballs

Passing Values to Dependencies

Values go under the dependency name in the parent's values.yaml:

yaml
1# values.yaml (parent chart)
2
3# Your app's own values
4replicaCount: 3
5image:
6  repository: my-app
7  tag: latest
8
9# Values passed to the redis dependency
10redis:
11  architecture: standalone
12  auth:
13    enabled: true
14    password: "my-redis-password"
15  master:
16    resources:
17      requests:
18        memory: 256Mi
19        cpu: 100m
20
21# Values passed to the postgresql dependency
22postgresql:
23  auth:
24    username: myuser
25    password: mypassword
26    database: mydb
27  primary:
28    resources:
29      requests:
30        memory: 512Mi

Everything under redis: is passed directly to the Redis chart as if it were that chart's own values.yaml. Check the dependency chart's documentation for available values.

Using Global Values

Global values are accessible from any chart in the dependency tree:

yaml
1# values.yaml (parent chart)
2global:
3  storageClass: "fast-ssd"
4  environment: production
5  imageRegistry: my-registry.example.com
6
7redis:
8  # Redis chart can access global.storageClass
9  master:
10    persistence:
11      storageClass: ""  # Will use global.storageClass if chart supports it
12
13postgresql:
14  # PostgreSQL chart can also access global values
15  primary:
16    persistence:
17      storageClass: ""

Inside any template (parent or dependency), access globals with:

yaml
# In a dependency chart's template
storageClass: {{ .Values.global.storageClass }}

Overriding at Install Time

bash
1# Override dependency values with --set
2helm install my-release ./my-app \
3  --set redis.auth.password=secret123 \
4  --set postgresql.auth.password=dbsecret
5
6# Override with a values file
7helm install my-release ./my-app -f production-values.yaml
yaml
1# production-values.yaml
2redis:
3  architecture: replication
4  replica:
5    replicaCount: 3
6  auth:
7    password: prod-redis-password
8
9postgresql:
10  auth:
11    password: prod-db-password
12  primary:
13    resources:
14      requests:
15        memory: 2Gi

Using import-values

Pull values from a dependency into the parent chart's namespace:

yaml
1# Chart.yaml
2dependencies:
3  - name: redis
4    version: "17.x.x"
5    repository: "https://charts.bitnami.com/bitnami"
6    import-values:
7      - child: master.service
8        parent: redisService
yaml
# Now in parent templates, you can access:
# {{ .Values.redisService.port }}
# Instead of looking up the Redis service details

Aliased Dependencies

Use the same chart multiple times with different configurations:

yaml
1# Chart.yaml
2dependencies:
3  - name: redis
4    version: "17.x.x"
5    repository: "https://charts.bitnami.com/bitnami"
6    alias: redis-cache
7  - name: redis
8    version: "17.x.x"
9    repository: "https://charts.bitnami.com/bitnami"
10    alias: redis-session
yaml
1# values.yaml
2redis-cache:
3  architecture: standalone
4  auth:
5    password: cache-password
6
7redis-session:
8  architecture: standalone
9  auth:
10    password: session-password

Each alias gets its own configuration namespace.

Conditional Dependencies

yaml
1# Chart.yaml
2dependencies:
3  - name: redis
4    version: "17.x.x"
5    repository: "https://charts.bitnami.com/bitnami"
6    condition: redis.enabled
7
8  - name: postgresql
9    version: "12.x.x"
10    repository: "https://charts.bitnami.com/bitnami"
11    condition: postgresql.enabled
yaml
1# values.yaml
2redis:
3  enabled: true
4  auth:
5    password: secret
6
7postgresql:
8  enabled: false  # PostgreSQL chart will not be installed
bash
# Toggle at install time
helm install my-release ./my-app --set redis.enabled=false

Accessing Dependency Values in Parent Templates

yaml
1# In parent chart templates, reference dependency service names
2apiVersion: v1
3kind: ConfigMap
4metadata:
5  name: app-config
6data:
7  REDIS_HOST: {{ .Release.Name }}-redis-master
8  REDIS_PORT: "6379"
9  DB_HOST: {{ .Release.Name }}-postgresql
10  DB_PORT: "5432"
11  DB_NAME: {{ .Values.postgresql.auth.database }}

Service names follow the pattern <release-name>-<dependency-name>. Check the dependency chart's NOTES.txt or templates for exact naming.

Debugging Values

bash
1# See all computed values (including dependency values)
2helm install my-release ./my-app --debug --dry-run
3
4# Check what values a dependency expects
5helm show values bitnami/redis
6
7# Render templates locally to verify
8helm template my-release ./my-app --debug

Common Pitfalls

  • Wrong nesting level: Values must be nested under the exact dependency name (or alias). redis.auth.password is correct; auth.password at the root level does not reach the Redis chart.
  • Forgetting helm dependency update: After changing Chart.yaml dependencies, run helm dependency update to download the new charts. Without this, Helm uses stale or missing chart versions.
  • Global values not supported by all charts: Not every chart reads global.* values. Check the dependency chart's values.yaml and templates to see if it uses .Values.global.
  • Alias vs name: When using alias, values go under the alias name, not the chart name. alias: redis-cache means values go under redis-cache:, not redis:.
  • Version constraints: version: "17.x.x" uses semver ranges. Running helm dependency update may pull a new minor/patch version with different value names. Pin exact versions for production.

Summary

  • Nest dependency values under the dependency name in values.yaml (e.g., redis:)
  • Use global: for values shared across parent and all dependency charts
  • Use --set redis.auth.password=secret to override dependency values at install time
  • Use alias to install the same dependency chart multiple times with different configs
  • Use condition to make dependencies optional (enable/disable at install time)
  • Always run helm dependency update after modifying Chart.yaml

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.