Composing complex applications from reusable chart building blocks.
Chart.yamlhelm dependency update & the charts/ directoryapiVersion: 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
condition and tags fields control whether the dependency is installed.# 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
helm dependency update — resolves versions, downloads .tgz archives, generates Chart.lockhelm dependency build — uses existing Chart.lock for deterministic buildscharts/charts/*.tgz to .gitignore and commit Chart.lock for reproducible CI/CD builds.# 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:
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.
postgresql: in the parent's values.yaml passes values down to the postgresql subchart.# 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"
--set tags.database=false# 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://..."
# 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.
type: library for shared helpers (labels, annotations, common templates). They are included via {{ include "mylib.labels" . }} but produce no manifests themselves.# 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"
~ (tilde) allows patch updates. ^ (caret) allows minor + patch. OCI repos use the oci:// scheme and do not need helm repo add..Values.global.* accessible everywheretype: library, reusable templates, no resources~, ^, explicit ranges for flexibilityoci:// repos, no helm repo add neededNext: Lesson 15 →