Lab 25 - Troubleshooting challenge
Lab 25 - Troubleshooting challenge
InfodiscoverGoal: a “production” namespace with several faults. Make it work using only what you learned in Days 1-3. Chapter: Troubleshooting and kubectl debug
The scenario
The shop team deployed to namespace challenge and went home. Nothing works.
Your definition of done:
frontendDeployment: 3/3 ready.workerDeployment: 1/1 ready.curl -H 'Host: shop.k8s.lab' http://worker01:30080returns the nginx page (Traefik + Gateway from Day 2).kubectl get events -n challenge --types=Warningshows nothing new.
Set it up - do not read the manifest, that is cheating:
cd ~
cat > challenge.yaml <<'YAML'
apiVersion: v1
kind: Namespace
metadata: { name: challenge }
---
apiVersion: v1
kind: ResourceQuota
metadata: { name: team, namespace: challenge }
spec:
hard: { pods: "3" }
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: frontend, namespace: challenge }
spec:
replicas: 3
selector: { matchLabels: { app: frontend } }
template:
metadata: { labels: { app: frontend } }
spec:
containers:
- name: nginx
image: nginx:1.27
envFrom: [{ configMapRef: { name: frontend-cfg } }]
readinessProbe:
httpGet: { path: /, port: 8080 }
periodSeconds: 3
---
apiVersion: v1
kind: Service
metadata: { name: frontend, namespace: challenge }
spec:
selector: { app: front-end }
ports: [{ port: 80, targetPort: 80 }]
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: worker, namespace: challenge }
spec:
replicas: 1
selector: { matchLabels: { app: worker } }
template:
metadata: { labels: { app: worker } }
spec:
nodeSelector: { disktype: nvme }
containers:
- name: worker
image: busybox:1.36
command: ["sh", "-c", "while true; do echo working; sleep 10; done"]
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: frontend, namespace: challenge }
spec:
parentRefs: [{ name: traefik-gateway, namespace: traefik }]
hostnames: ["shop.k8s.lab"]
rules:
- backendRefs: [{ name: frontend, port: 80 }]
YAML
kubectl apply -f challenge.yaml
kubectl config set-context --current --namespace=challenge
Work the routine: get -> describe / events -> logs. Fix faults with
kubectl commands (edit, patch, create, scale) - one at a time, and re-check
after each fix; new problems appear when old ones are solved.
Hints
Open a hint only when stuck for 5 minutes.
Solution
Clean up
kubectl config set-context --current --namespace=default
kubectl delete ns challenge