Homework
Apply validation and linting skills to a realistic chart with comprehensive schema enforcement.
Submission: For each task, include the files you created or modified and screenshots of command output showing successful validation (or expected failures). Be prepared to walk through your schema design decisions in class.
Task 1 — Comprehensive values.schema.json
Create a new Helm chart (helm create webapp) and write a values.schema.json that enforces all of the following constraints:
replicaCountis a required integer between 1 and 50image.repositoryis a required non-empty stringimage.tagmust match semver pattern:^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$image.pullPolicymust be one ofAlways,IfNotPresent, orNeverservice.typemust be one ofClusterIP,NodePort, orLoadBalancerservice.portmust be an integer between 1 and 65535ingress.enabledmust be a booleanresources.limitsandresources.requestsare objects with optionalcpu(string) andmemory(string) fields
After writing the schema:
- Run
helm lint .with the defaultvalues.yaml— fix any issues until it passes - Create a
test-bad-values.yamlwith at least 5 distinct schema violations and verify they are all reported
Self-check
helm lint .passes with zero warningshelm lint . -f test-bad-values.yamlreports at least 5 distinct validation errors- Your schema covers all 8 constraints listed above
Task 2 — Full Validation Pipeline Script
Write a shell script called ci-validate.sh that implements the complete validation pipeline for any chart directory passed as an argument:
- Stage 1:
helm lint --strict - Stage 2:
helm templaterenders without errors - Stage 3:
kubeconform -strictvalidates rendered YAML against a configurable Kubernetes version (default 1.29.0, overridable viaK8S_VERSIONenvironment variable)
Requirements:
- The script must exit immediately on the first stage failure (
set -euo pipefail) - Each stage must print a clear header (e.g.,
==> Stage 1: Linting...) - On success, print a summary line; on failure, print which stage failed
- Support an optional
-f values-file.yamlflag to pass a custom values file to all stages
Test the script against your Task 1 chart with both valid and invalid values.
Self-check
./ci-validate.sh ./webapppasses all three stages./ci-validate.sh ./webapp -f test-bad-values.yamlfails at Stage 1 (lint catches schema violations)K8S_VERSION=1.28.0 ./ci-validate.sh ./webappuses the specified Kubernetes version
Task 3 — Error Catalogue
Create a document (text file or markdown) that catalogues at least 8 distinct Helm chart errors, organized by which tool catches them. For each error, provide:
- The exact code or configuration that causes the error
- Which tool detects it (
helm lint,helm template,kubeconform, orhelm install --dry-run=server) - The error message produced
- The fix
Your catalogue must include at least two errors from each of these categories:
- Structural: missing Chart.yaml fields, invalid YAML syntax
- Template: nil pointers, scope errors, wrong indentation
- Schema: type mismatches, enum violations, missing required fields
- Kubernetes: misspelled fields, deprecated APIs, invalid resource specs
Self-check
- At least 8 errors documented
- At least 2 from each of the 4 categories
- Each entry includes: broken code, detecting tool, error message, and fix
Grading Rubric
| Criterion | Points | Requirements |
|---|---|---|
| Task 1 — Schema completeness | 30 | All 8 constraints implemented; passes with valid values; rejects bad values with 5+ errors |
| Task 2 — Pipeline script | 35 | Three stages in order; fails fast; configurable K8s version; supports -f flag; tested both ways |
| Task 3 — Error catalogue | 25 | 8+ errors; 2+ per category; each with code, tool, message, and fix |
| Code quality & presentation | 10 | Clean script; well-formatted schema; clear documentation |