Homework
Complete these tasks before the next lesson. They reinforce dependency management, subchart overrides, and conditional toggling in Helm charts.
Task 1: Multi-Dependency Chart with Conditional Subcharts
Goal: Build an application chart that declares three dependencies (PostgreSQL, Redis, and Memcached), uses conditions and tags to toggle them, and passes configuration through global values.
Instructions
- Create a new chart called
taskapp:helm create taskapp cd taskapp - Edit
Chart.yamlto declare three dependencies:
Replace thedependencies: - name: postgresql version: "13.x.x" # use a valid version range repository: "https://charts.bitnami.com/bitnami" condition: postgresql.enabled tags: - database - name: redis version: "18.x.x" repository: "https://charts.bitnami.com/bitnami" condition: redis.enabled tags: - cache - name: memcached version: "7.x.x" repository: "https://charts.bitnami.com/bitnami" condition: memcached.enabled tags: - cachex.xportions with valid version numbers from the Bitnami repository. - In
values.yaml, define global values and subchart overrides:global: storageClass: "standard" imageRegistry: "" postgresql: enabled: true auth: database: taskapp_db username: taskapp_user redis: enabled: true architecture: standalone memcached: enabled: false tags: database: true cache: true - Run
helm dependency updateand confirm tarballs appear incharts/. - Template the chart with memcached disabled and verify no Memcached resources appear:
helm template taskapp . | grep -i memcached - Template again with memcached enabled via the command line:
Confirm Memcached resources now appear.helm template taskapp . --set memcached.enabled=true | grep -i memcached - Template once more, disabling the entire
cachetag group:
Confirm neither Redis nor Memcached resources appear.helm template taskapp . --set tags.cache=false | grep -iE "redis|memcached"
Deliverable
Your Chart.yaml, values.yaml, and terminal output showing:
- Successful
helm dependency updatewith three tarballs incharts/ - Memcached absent when disabled, present when enabled
- Both Redis and Memcached absent when
tags.cache=false
Self-check
- ✓ All three dependencies are declared with valid version ranges in
Chart.yaml - ✓ Each dependency has both a
conditionand atagsentry - ✓
helm dependency updatesucceeds and creates.tgzfiles incharts/ - ✓
conditionoverridestagswhen both are set (memcached.enabled=true overrides tags.cache=false) - ✓ Global values (
global.storageClass) are accessible by subcharts
Task 2: OCI-Based Dependency and Version Pinning
Goal: Replace a traditional HTTPS repository dependency with an OCI registry reference, and explore version range semantics.
Instructions
- Create a new chart called
ociappand declare a single dependency using the OCI protocol:dependencies: - name: redis version: "18.6.1" repository: "oci://registry-1.docker.io/bitnamicharts" - Run
helm dependency build(note:build, notupdate, is required for OCI) and verify the tarball is pulled. - Now experiment with version ranges. Modify the version field using each of these range expressions one at a time, running
helm dependency buildafter each change:">=18.0.0 <19.0.0"— any 18.x release"~18.6.0"— patch-level updates only (18.6.x)"^18.0.0"— minor and patch updates (18.x.x)
- After each build, check which exact version was resolved:
ls charts/ cat Chart.lock - Document the resolved version for each range expression.
Deliverable
A summary table showing:
| Range Expression | Resolved Version |
|---|---|
"18.6.1" (exact) | (your result) |
">=18.0.0 <19.0.0" | (your result) |
"~18.6.0" | (your result) |
"^18.0.0" | (your result) |
Self-check
- ✓ The OCI repository URL uses
oci://protocol (nohelm repo addneeded) - ✓
helm dependency buildsucceeds for OCI references - ✓ You understand the difference between
~(patch only) and^(minor + patch) ranges - ✓
Chart.lockrecords the exact resolved version for each range
Task 3: Subchart Value Overrides and Global Propagation
Goal: Demonstrate mastery of the three mechanisms for passing values to subcharts: nested keys, import-values, and global.
Instructions
- Using your
taskappchart from Task 1, create a ConfigMap template that reads both parent and global values:# templates/config.yaml apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-config data: DB_HOST: {{ .Release.Name }}-postgresql REDIS_HOST: {{ .Release.Name }}-redis-master STORAGE_CLASS: {{ .Values.global.storageClass }} ENVIRONMENT: {{ .Values.global.environment | default "development" }} - Add a new global value in
values.yaml:global: storageClass: "standard" environment: "staging" - Override the PostgreSQL subchart password using the nested-key approach:
helm template taskapp . \ --set postgresql.auth.password=secretpass123 \ --set global.environment=production - Inspect the rendered output and confirm:
- The ConfigMap shows
ENVIRONMENT: production(overridden from CLI) - The PostgreSQL Secret contains the password you specified
- The PostgreSQL StatefulSet uses
global.storageClassfor its PVC
- The ConfigMap shows
- Finally, explore the
import-valuesmechanism. Add anexportssection to your dependency declaration:
Template and confirm thatdependencies: - name: postgresql version: "13.x.x" repository: "https://charts.bitnami.com/bitnami" condition: postgresql.enabled import-values: - child: primary.service parent: dbService.Values.dbService.ports.postgresqlis populated from the subchart defaults.
Deliverable
Rendered template output showing:
- The ConfigMap with correct global value overrides
- Evidence that nested-key overrides reach the subchart
- Evidence that
import-valuespulls child values into the parent scope
Self-check
- ✓ Global values appear in both parent templates and subchart resources
- ✓ CLI
--setoverrides propagate through global and nested-key paths - ✓
import-valuessuccessfully maps a child key into the parent value tree - ✓ You can explain the precedence order: CLI > values file > subchart defaults
Grading Rubric
| Criterion | Excellent | Satisfactory | Needs Work |
|---|---|---|---|
| Dependency declaration | All dependencies have valid version ranges, conditions, and tags; Chart.lock is generated correctly | Dependencies declared but missing conditions or tags | Dependencies incomplete or helm dependency update fails |
| Condition & tag toggling | Demonstrates condition overriding tags; shows both individual and group toggling with evidence | One toggling mechanism demonstrated | No evidence of conditional dependency toggling |
| OCI dependencies | OCI pull works; version range differences are documented with resolved versions for each | OCI pull works but range comparison is incomplete | OCI dependency not attempted |
| Value override mechanisms | All three mechanisms demonstrated (nested keys, global, import-values) with rendered proof | Two of three mechanisms demonstrated | Only basic nested-key overrides shown |
| Understanding & explanation | Can articulate precedence rules, when to use global vs nested keys, and trade-offs of version pinning vs ranges | General understanding shown but explanations lack depth | Cannot explain the mechanisms beyond copying examples |
Submission
There is no formal submission for this course. These tasks are for your own development. However:
- Keep your
taskappandociappcharts — you will extend them in future lessons. - If you are working with a group or mentor, share your version-range summary table for discussion.
- Ensure all three tasks are complete before the next lesson.
Next lesson: Lesson 15 — Hooks & Tests.