Lesson 04 Namespaces & Labels
Theme:

Homework: Namespaces & Labels

Three tasks that reinforce namespace isolation, labelling strategy, and quota enforcement

Instructions

Complete each task independently. Use the self-check criteria to verify your work before moving on. You may reference the theory reading and lab guide, but try to work from memory first.

Task 1: Multi-Namespace Deployment

Create a Helm chart called hw04-multi. Deploy the same chart into three namespaces: hw04-dev, hw04-staging, and hw04-prod. Each installation should use a different release name (e.g., app-dev, app-staging, app-prod).

After deploying, run a single kubectl command that lists pods across all three namespaces filtered by the label app.kubernetes.io/name=hw04-multi.

Self-Check

Task 2: Custom Label Strategy with Annotations

Extend the chart from Task 1 (or create a new one) to include the following metadata on every resource:

All labels and annotations must be defined in _helpers.tpl using named templates. The cost-center label must not be included in matchLabels.

Self-Check

Task 3: ResourceQuota & LimitRange Guard Rails

Add both a ResourceQuota and a LimitRange template to your chart. They should be toggled via .Values.resourceQuota.enabled and .Values.limitRange.enabled respectively. Configure the following defaults:

Deploy with both enabled, then attempt to create a pod that exceeds the LimitRange default limit by adding resources.limits.memory: 2Gi to a second deployment.

Self-Check

Grading Rubric

CriterionPointsDescription
Task 1: Multi-namespace deployment30Three releases across three namespaces; cross-namespace label query returns all pods.
Task 2: Label strategy35All six standard labels present; custom label and annotation from values; selector labels remain minimal.
Task 3: Quota & LimitRange25Both resources correctly templated and gated behind values; defaults are applied to new pods.
Code quality10Labels centralised in _helpers.tpl; values have sensible defaults; templates pass helm lint.

Cleanup

When finished, uninstall all releases and delete the homework namespaces:

helm uninstall app-dev -n hw04-dev
helm uninstall app-staging -n hw04-staging
helm uninstall app-prod -n hw04-prod
kubectl delete ns hw04-dev hw04-staging hw04-prod