Lesson 18 Chart Packaging & Registries
Theme:

Homework — Chart Packaging & Registries

Apply what you learned about packaging, repositories, OCI registries, and CI/CD pipelines.

Task 1 — GitHub Pages Chart Repository

Set up a chart repository hosted on GitHub Pages. This simulates a real open-source chart distribution workflow.

  1. Create a new GitHub repository (or use an existing one) and enable GitHub Pages on the docs/ folder of the main branch.
  2. Create a Helm chart called myservice with version: 1.0.0 and appVersion: "2.0.0".
  3. Write a .helmignore that excludes .git, *.md, tests/, ci/, .env, and editor swap files.
  4. Package the chart into the docs/ directory.
  5. Generate index.yaml with your GitHub Pages URL as the base URL.
  6. Commit, push, and verify the repo works:
    helm repo add mypages https://<username>.github.io/<repo>
    helm repo update
    helm search repo mypages/myservice
  7. Bump the chart to version: 1.1.0, re-package, regenerate the index (use --merge to preserve existing entries), commit, and push.
  8. Verify both versions are discoverable with helm search repo mypages/myservice --versions.

Self-Check

Task 2 — OCI Multi-Version Release Pipeline

Build a shell script that automates the full lint-package-push pipeline for an OCI registry.

  1. Start a local OCI registry: docker run -d -p 5000:5000 --name hw-registry registry:2
  2. Create a shell script called release.sh that accepts a chart directory and a version as arguments and performs:
    #!/usr/bin/env bash
    set -euo pipefail
    
    CHART_DIR="$1"
    VERSION="$2"
    REGISTRY="oci://localhost:5000/charts"
    
    # Step 1: Lint
    helm lint "$CHART_DIR" --strict
    
    # Step 2: Package with version override
    helm package "$CHART_DIR" --version "$VERSION" -d ./build/
    
    # Step 3: Push to OCI registry
    ARCHIVE="./build/$(basename "$CHART_DIR")-${VERSION}.tgz"
    helm push "$ARCHIVE" "$REGISTRY"
    
    echo "Released $(basename "$CHART_DIR") v${VERSION}"
  3. Run the script three times to release versions 1.0.0, 1.1.0, and 2.0.0-rc1 of your chart.
  4. Verify all three tags exist in the registry:
    curl -s http://localhost:5000/v2/charts/<name>/tags/list
  5. Pull each version and confirm the Chart.yaml inside has the correct version.

Self-Check

Task 3 — GitHub Actions CI/CD Workflow (Stretch)

Write a GitHub Actions workflow that automates chart releases on tag pushes.

  1. Create .github/workflows/helm-release.yaml in a GitHub repository.
  2. Trigger on pushes of tags matching v* (e.g., v1.2.0).
  3. The workflow should:
    • Check out the repository.
    • Install Helm using azure/setup-helm@v4.
    • Run helm lint --strict.
    • Run helm template to validate rendered output.
    • Package the chart with the version derived from the tag (${GITHUB_REF_NAME#v}).
    • Authenticate to GitHub Container Registry using GITHUB_TOKEN.
    • Push to oci://ghcr.io/${{ github.repository_owner }}/charts.
  4. Test by creating and pushing a tag: git tag v1.0.0 && git push origin v1.0.0.
  5. Verify the chart appears in your GitHub Packages page.

Self-Check

Grading Rubric

CriterionPointsDescription
Task 1 — GitHub Pages repo works35Both chart versions are discoverable via helm search repo; index.yaml is correct; .helmignore is present and effective.
Task 2 — OCI pipeline script40Script lints, packages, and pushes; all three versions appear in registry; set -euo pipefail ensures failure stops the pipeline; pulled charts have correct metadata.
Task 3 — GitHub Actions workflow25Workflow file is syntactically valid; includes lint, template, package, and push stages; uses tag-derived versioning; authenticates correctly to GHCR.
Total100
Note: Task 3 is a stretch goal. If you do not have a GitHub account or prefer not to push to a public registry, you can write the workflow file locally and validate it with actionlint or the online checker without actually running it.