Lesson 14 Dependencies & Subcharts
Theme:
Lesson 14 · Slide 1

Dependencies & Subcharts

Composing complex applications from reusable chart building blocks.

Lesson 14 · Slide 2

Declaring Dependencies in Chart.yaml

apiVersion: v2
name: myapp
version: 1.0.0

dependencies:
  - name: postgresql
    version: "13.2.24"
    repository: "https://charts.bitnami.com/bitnami"
    condition: postgresql.enabled
    tags:
      - database

  - name: redis
    version: "18.6.1"
    repository: "https://charts.bitnami.com/bitnami"
    condition: redis.enabled
    tags:
      - cache

  - name: common
    version: "2.x.x"
    repository: "https://charts.bitnami.com/bitnami"
    tags:
      - infra
Notes: Each dependency has a name, version, and repository. The condition and tags fields control whether the dependency is installed.
Lesson 14 · Slide 3

helm dependency update & charts/

# Download dependencies into charts/ directory
$ helm dependency update ./myapp
Saving 3 charts
Downloading postgresql from repo https://charts.bitnami.com/bitnami
Downloading redis from repo https://charts.bitnami.com/bitnami
Downloading common from repo https://charts.bitnami.com/bitnami
Deleting outdated charts

# Rebuild from Chart.lock (reproducible builds)
$ helm dependency build ./myapp
Notes: Add charts/*.tgz to .gitignore and commit Chart.lock for reproducible CI/CD builds.
Lesson 14 · Slide 4

Subchart Value Overrides

Parent values.yaml

# Override postgresql subchart values
postgresql:
  enabled: true
  auth:
    username: myapp
    database: myapp_db
    existingSecret: myapp-db-secret
  primary:
    persistence:
      size: 20Gi

# Override redis subchart values
redis:
  enabled: true
  architecture: standalone
  auth:
    enabled: false
  master:
    persistence:
      size: 5Gi

Global values

global:
  storageClass: "gp3"
  imageRegistry: "registry.example.com"
  imagePullSecrets:
    - name: registry-creds

Global values are accessible from every chart and subchart via .Values.global.*.

Use globals for cross-cutting concerns: registry, storage class, domain names.

Notes: Parent chart values are keyed by the dependency name. A key postgresql: in the parent's values.yaml passes values down to the postgresql subchart.
Lesson 14 · Slide 5

Conditions & Tags

# Chart.yaml
dependencies:
  - name: postgresql
    condition: postgresql.enabled    # single boolean check
    tags:
      - database                     # group toggle
  - name: mysql
    condition: mysql.enabled
    tags:
      - database
# values.yaml
postgresql:
  enabled: true
mysql:
  enabled: false

tags:
  database: true    # enables all charts tagged "database"
  cache: false      # disables all charts tagged "cache"
Lesson 14 · Slide 6

Library Charts & import-values

Library Chart

# Chart.yaml of the library
apiVersion: v2
name: mylib
type: library
version: 1.0.0

Library charts provide reusable templates but never deploy resources on their own.

# In parent Chart.yaml
dependencies:
  - name: mylib
    version: "1.x.x"
    repository: "https://..."

import-values

# Chart.yaml
dependencies:
  - name: postgresql
    version: "13.2.24"
    repository: "https://..."
    import-values:
      - child: primary.service
        parent: dbService
      - child: auth
        parent: dbAuth

Import specific subchart values into the parent scope.

child = path in subchart, parent = key in parent values.

Notes: Use type: library for shared helpers (labels, annotations, common templates). They are included via {{ include "mylib.labels" . }} but produce no manifests themselves.
Lesson 14 · Slide 7

Version Ranges & OCI Dependencies

# Semantic version ranges
dependencies:
  - name: redis
    version: "~18.6.0"     # >=18.6.0, <18.7.0  (patch updates only)
    repository: "https://charts.bitnami.com/bitnami"

  - name: postgresql
    version: "^13.2.0"     # >=13.2.0, <14.0.0  (minor + patch updates)
    repository: "https://charts.bitnami.com/bitnami"

  - name: kafka
    version: ">=26.0.0 <27.0.0"  # explicit range
    repository: "https://charts.bitnami.com/bitnami"
# OCI-based dependencies (Helm 3.8+)
dependencies:
  - name: nginx
    version: "15.4.4"
    repository: "oci://registry-1.docker.io/bitnamicharts"
Notes: ~ (tilde) allows patch updates. ^ (caret) allows minor + patch. OCI repos use the oci:// scheme and do not need helm repo add.
Lesson 14 · Slide 8

Summary

Next: Lesson 15 →

1 / ?