CKAD — Helm & Kustomize Lab
Lab 1: Helm Install, Upgrade, Rollback
Practice the full Helm lifecycle — install, inspect, upgrade, view history, roll back, and uninstall.
# Add the bitnami repo
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
# Install Redis with custom values
helm install my-redis bitnami/redis \
--set architecture=standalone \
--set auth.password=mypassword
# Check the release
helm list
helm status my-redis
# Upgrade to a specific chart version
helm upgrade my-redis bitnami/redis \
--set architecture=standalone \
--set auth.password=mypassword \
--set replica.replicaCount=0
# Check history
helm history my-redis
# Roll back to revision 1
helm rollback my-redis 1
# Clean up
helm uninstall my-redis
What to observe:
helm listshows the release with its revision numberhelm historyshows all revisions and their status- After
helm rollback, the revision number increments (it creates a new revision)
Lab 2: Kustomize Base and Overlay
Build a Kustomize project from scratch with a base and two overlays (dev and prod).
# Create the directory structure
mkdir -p kustomize-lab/base kustomize-lab/overlays/{dev,prod}
# Create base deployment
cat <<EOF > kustomize-lab/base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.26
ports:
- containerPort: 80
EOF
# Create base kustomization
cat <<EOF > kustomize-lab/base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
EOF
# Create dev overlay
cat <<EOF > kustomize-lab/overlays/dev/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namePrefix: dev-
namespace: dev
images:
- name: nginx
newTag: "1.27"
EOF
# Create prod overlay (3 replicas)
cat <<EOF > kustomize-lab/overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namePrefix: prod-
namespace: production
patches:
- target:
kind: Deployment
name: web
patch: |
- op: replace
path: /spec/replicas
value: 3
images:
- name: nginx
newTag: "1.27"
EOF
# Preview dev
kubectl kustomize kustomize-lab/overlays/dev/
# Expected: Deployment named "dev-web" in namespace "dev" with nginx:1.27
# Preview prod
kubectl kustomize kustomize-lab/overlays/prod/
# Expected: Deployment named "prod-web" in namespace "production" with 3 replicas
# Apply dev
kubectl create namespace dev
kubectl apply -k kustomize-lab/overlays/dev/
kubectl get deployment -n dev
Practice Questions
Q1: Install a Helm chart named bitnami/nginx as release web-server with 3 replicas.
Show Answer
```bash helm repo add bitnami https://charts.bitnami.com/bitnami helm install web-server bitnami/nginx --set replicaCount=3 ``` Verify: ```bash helm list helm status web-server ```Q2: You upgraded a Helm release and it broke. How do you roll back to revision 2?
Show Answer
```bash # Check history helm history my-release # Roll back to revision 2 helm rollback my-release 2 # Verify helm status my-release ```Q3: What does kubectl apply -k overlays/prod/ do?
Show Answer
It applies all Kubernetes resources defined in the Kustomize overlay at `overlays/prod/`. Kustomize reads the `kustomization.yaml` file in that directory, resolves the base resources, applies all patches, transformations (namePrefix, namespace, labels, image overrides), and then creates/updates the resources in the cluster.Q4: Write a kustomization.yaml that takes a base from ../../base, adds the namespace staging, and changes the image tag to v2.5.
Show Answer
```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../../base namespace: staging images: - name: myapp newTag: "v2.5" ```Q5: What is the command to see the default values of a Helm chart before installing it?
Show Answer
```bash helm show values bitnami/nginx ``` You can also redirect to a file and edit it: ```bash helm show values bitnami/nginx > values.yaml # Edit values.yaml as needed helm install my-release bitnami/nginx -f values.yaml ```← Previous: Deployments & Rolling Updates Next: Probes & Health Checks →