Lesson 02 Your First Chart
Theme:

Homework

Complete these tasks before Lesson 03. Focus on customizing charts and understanding the relationship between values, templates, and rendered output.

Task 1: Customize a Chart for a Real Application

Goal: Modify the scaffolded chart to deploy a different application image with custom configuration, demonstrating your understanding of values.yaml and Chart.yaml.

Instructions

  1. Scaffold a new chart:
    helm create webapp
  2. Edit webapp/Chart.yaml:
    • Change description to something meaningful (e.g., "A custom web application chart")
    • Set appVersion to "latest"
  3. Edit webapp/values.yaml to customize the deployment:
    • Change image.repository to httpd (Apache) or another image of your choice
    • Set image.tag to "2.4"
    • Set replicaCount to 2
    • Set service.type to NodePort
    • Set service.port to 80
  4. Render the templates locally and verify the output:
    helm template my-webapp webapp
  5. Install the chart, verify the pods are running, then uninstall:
    helm install my-webapp webapp
    kubectl get pods -l app.kubernetes.io/instance=my-webapp
    helm uninstall my-webapp

Self-Check

Task 2: Write a Custom NOTES.txt

Goal: Replace the default NOTES.txt template with a custom one that displays useful information based on the chart’s configured values.

Instructions

  1. Using the webapp chart from Task 1, open webapp/templates/NOTES.txt.
  2. Replace the contents with a custom template that:
    • Displays the release name and namespace
    • Shows the image and tag being deployed
    • Provides the correct access command based on .Values.service.type (ClusterIP vs. NodePort)
  3. Your NOTES.txt should use at least these template variables:
    • {{ .Release.Name }}
    • {{ .Release.Namespace }}
    • {{ .Values.image.repository }}
    • {{ .Values.image.tag }}
    • {{ .Values.service.type }}
  4. Test your NOTES.txt output:
    # Render locally to preview
    helm template my-webapp webapp --show-only templates/NOTES.txt
    
    # Install and verify the notes display correctly
    helm install my-webapp webapp
    helm status my-webapp
  5. Clean up:
    helm uninstall my-webapp

Self-Check

Task 3: Multi-Revision Lifecycle Report

Goal: Perform multiple upgrades and a rollback, then document the full revision history to demonstrate your understanding of the Helm release lifecycle.

Instructions

  1. Install the chart:
    helm install my-webapp webapp
  2. Perform three upgrades, changing a value each time:
    # Upgrade 1: scale to 3 replicas
    helm upgrade my-webapp webapp --set replicaCount=3
    
    # Upgrade 2: change image tag
    helm upgrade my-webapp webapp --set replicaCount=3 --set image.tag="2.4-alpine"
    
    # Upgrade 3: switch service to ClusterIP
    helm upgrade my-webapp webapp --set replicaCount=3 --set image.tag="2.4-alpine" --set service.type=ClusterIP
  3. View the full history:
    helm history my-webapp
  4. Roll back to revision 2:
    helm rollback my-webapp 2
  5. Document your findings:
    • How many revisions exist after the rollback?
    • What is the status of each revision?
    • What values are active after the rollback? (Use helm get values my-webapp)
  6. Clean up:
    helm uninstall my-webapp
    rm -rf webapp

Self-Check

Grading Rubric

CriterionPointsDescription
Task 1: Custom values30Chart deploys with custom image, replicas, and service type
Task 1: Rendered output10helm template output matches expected configuration
Task 2: NOTES.txt template20Custom template renders correctly with dynamic values
Task 2: Conditional logic10Output adapts based on service type
Task 3: Lifecycle commands15All install/upgrade/rollback/uninstall commands succeed
Task 3: History analysis15Correct understanding of revision numbering and rollback behavior
Total100

Stretch Goal

Create a production-values.yaml file that overrides multiple values at once (replicas, resources, service type, ingress settings). Install the chart using helm install my-webapp webapp -f production-values.yaml and verify all overrides are applied with helm get values my-webapp -a.