Перейти до вмісту
CKA DEPLOYMENT & SERVICE LAB #2
Source: Dev.to | Jan 08, 2026 (UTC)
GLOBAL RULES
- Do NOT use
kubectl edit
- Do NOT recreate resources unless asked
- Fix issues using kubectl patch / set / scale / rollout
- Namespace must be used
- Treat this like a real CKA exam
🟢 BASELINE (RUN ON EVERY MACHINE)
Step 0 — Start cluster
minikube start --driver=docker
Enter fullscreen mode
Exit fullscreen mode
Step 1 — Namespace
kubectl create namespace cka-lab kubectl config set-context --current --namespace=cka-lab
Enter fullscreen mode
Exit fullscreen mode
Step 2 — Apply BASE WORKLOAD (DO NOT MODIFY)
kubectl apply -f - <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: web-app spec: replicas: 4 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: nginx image: nginx:1.25 ports: - containerPort: 80 EOF
Enter fullscreen mode
Exit fullscreen mode
Step 3 — Apply BASE SERVICE (DO NOT MODIFY)
kubectl apply -f - <<EOF apiVersion: v1 kind: Service metadata: name: web-svc spec: selector: app: web ports: - port: 80 targetPort: 80 type: ClusterIP EOF
Enter fullscreen mode
Exit fullscreen mode
Step 4 — Traffic test pod (keep running)
kubectl run traffic --image=busybox -it --rm -- sh
Enter fullscreen mode
Exit fullscreen mode
Inside:
while true; do wget -qO- web-svc echo "-----" sleep 1 done
Enter fullscreen mode
Exit fullscreen mode
🧪 TASK 1 — ROLLING UPDATE MISCONFIGURATION
PROBLEM SETUP
kubectl patch deployment web-app -p ' { "spec": { "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 4, "maxSurge": 0 } } } }'
Enter fullscreen mode
Exit fullscreen mode
TASK
- Fix the deployment strategy
- Ensure no downtime during image updates
SUCCESS CRITERIA
- Traffic loop never stops
- At least one pod always available
🧪 TASK 2 — BROKEN IMAGE DEPLOYMENT
PROBLEM SETUP
kubectl set image deployment/web-app nginx=nginx:doesnotexist
Enter fullscreen mode
Exit fullscreen mode
TASK
- Restore the deployment to a healthy state
- Do NOT delete the deployment
SUCCESS CRITERIA
- All pods Running
- No CrashLoopBackOff
- Traffic loop stable
🧪 TASK 3 — MISSING READINESS PROBE
PROBLEM SETUP
kubectl patch deployment web-app --type=json -p='[ { "op": "remove", "path": "/spec/template/spec/containers/0/readinessProbe" } ]'
Enter fullscreen mode
Exit fullscreen mode
TASK
- Ensure traffic is only sent to ready pods
- Do NOT restart the cluster
SUCCESS CRITERIA
- During rollout, traffic never hits unready pods
🧪 TASK 4 — SERVICE TRAFFIC FAILURE
PROBLEM SETUP
kubectl patch svc web-svc -p ' { "spec": { "selector": { "app": "wrong" } } }'
Enter fullscreen mode
Exit fullscreen mode
TASK
- Restore service traffic
- Do NOT recreate the service
SUCCESS CRITERIA
-
Endpoints populated
- Traffic loop resumes
🧪 TASK 5 — CANARY DEPLOYMENT (TRAFFIC LEAK)
PROBLEM SETUP
kubectl create deployment web-app-canary --image=nginx:1.27 --replicas=1 kubectl label deployment web-app-canary track=canary
Enter fullscreen mode
Exit fullscreen mode
TASK
- Canary must receive traffic
- Stable workload must remain untouched
SUCCESS CRITERIA
- Service routes traffic to both versions
- No service recreation
🧪 TASK 6 — CANARY ROLLBACK
PROBLEM SETUP
(canary from previous task is faulty)
TASK
- Remove canary from traffic immediately
- Stable version must continue serving traffic
SUCCESS CRITERIA
- Traffic uninterrupted
- Only stable pods receive traffic
🧪 TASK 7 — PAUSED ROLLOUT INCIDENT
PROBLEM SETUP
kubectl rollout pause deployment web-app kubectl set image deployment/web-app nginx=nginx:1.26
Enter fullscreen mode
Exit fullscreen mode
TASK
- Identify why rollout is stuck
- Complete the deployment
SUCCESS CRITERIA
- New image fully deployed
- Deployment not paused
🧪 TASK 8 — NODEPORT ACCESS FAILURE
PROBLEM SETUP
kubectl patch svc web-svc -p ' { "spec": { "type": "NodePort" } }'
Enter fullscreen mode
Exit fullscreen mode
Traffic still unreachable.
TASK
- Make application reachable from browser
- Do NOT recreate Service or Deployment
SUCCESS CRITERIA
- Browser access works
- NodePort correctly assigned
🧪 TASK 9 — SCALING INCIDENT
PROBLEM SETUP
kubectl scale deployment web-app --replicas=0
Enter fullscreen mode
Exit fullscreen mode
TASK
- Restore service availability
- Do NOT recreate pods manually
SUCCESS CRITERIA
- Pods running
- Traffic restored
🧪 TASK 10 — FINAL CLEANUP
TASK
- Remove all resources created in this lab
- Namespace must be empty
SUCCESS CRITERIA
kubectl get all
Enter fullscreen mode
Exit fullscreen mode
→ No resources found
For further actions, you may consider blocking this person and/or reporting abuse
Залишити відповідь