Step-by-Step Guide: Troubleshooting Scenarios
This guide walks through using the troubleshooting scenarios to build your debugging skills.
Prerequisites
kubectlinstalledkindinstalled- Basic Kubernetes knowledge
- Willingness to learn!
Setup
Step 1: Create Cluster
bash
cd labs/09-troubleshooting-scenarios
# Create Kind cluster
kind create cluster --name troubleshooting-lab
# Verify cluster
kubectl cluster-infoStep 2: Setup Scenarios
bash
# Run setup script
./scripts/setup-scenarios.shWorking Through Scenarios
Scenario Workflow
For each scenario:
Read the Scenario:
bashcat scenarios/[scenario-name]/scenario.mdRun the Simulation:
bash./scenarios/[scenario-name]/simulate.shObserve the Problem:
bashkubectl get pods -A kubectl get events --sort-by='.lastTimestamp'Diagnose (Try First!):
- Use systematic debugging methodology
- Use diagnostic tools
- Form hypotheses
- Test hypotheses
Follow Diagnosis Guide (If Stuck):
bashcat scenarios/[scenario-name]/diagnosis.mdApply Resolution:
bashcat scenarios/[scenario-name]/resolution.mdVerify Fix:
- Check pod status
- Test functionality
- Verify resolution
Scenario 1: Network Connectivity
Step 1: Run Simulation
bash
./scenarios/network-connectivity/simulate.shStep 2: Observe
bash
kubectl get pods -n network-test
kubectl get events -n network-testStep 3: Diagnose
Try First:
- Check pod status
- Test connectivity
- Check network policies
- Review service endpoints
If Stuck:
bash
cat scenarios/network-connectivity/diagnosis.mdStep 4: Resolve
bash
cat scenarios/network-connectivity/resolution.md
# Follow resolution stepsStep 5: Verify
bash
kubectl exec client-pod -n network-test -- wget -O- http://test-serviceScenario 2: Resource Exhaustion
Step 1: Run Simulation
bash
./scenarios/resource-exhaustion/simulate.shStep 2: Observe
bash
kubectl get pods -n resource-test
kubectl top pods -n resource-test
kubectl get resourcequota -n resource-testStep 3: Diagnose
Try First:
- Check pod status
- Check resource usage
- Check resource quotas
- Review events
If Stuck:
bash
cat scenarios/resource-exhaustion/diagnosis.mdStep 4: Resolve
bash
cat scenarios/resource-exhaustion/resolution.md
# Follow resolution stepsStep 5: Verify
bash
kubectl get pods -n resource-test
# All pods should be RunningScenario 3: Permission Denied
Step 1: Run Simulation
bash
./scenarios/permission-denied/simulate.shStep 2: Observe
bash
kubectl get pods -n permission-test
kubectl logs permission-test-pod -n permission-testStep 3: Diagnose
Try First:
- Check pod logs
- Check service account
- Check RBAC configuration
- Test permissions
If Stuck:
bash
cat scenarios/permission-denied/diagnosis.mdStep 4: Resolve
bash
cat scenarios/permission-denied/resolution.md
# Follow resolution stepsStep 5: Verify
bash
kubectl logs permission-test-pod -n permission-test
# Should show successful pod listScenario 4: Image Pull Failures
Step 1: Run Simulation
bash
./scenarios/image-pull-failures/simulate.shStep 2: Observe
bash
kubectl get pods -n image-test
kubectl describe pod image-pull-fail-pod -n image-testStep 3: Diagnose
Try First:
- Check pod events
- Verify image name
- Check image pull secrets
- Test image pull
If Stuck:
bash
cat scenarios/image-pull-failures/diagnosis.mdStep 4: Resolve
bash
cat scenarios/image-pull-failures/resolution.md
# Follow resolution stepsStep 5: Verify
bash
kubectl get pods -n image-test
# Pod should be RunningScenario 5: DNS Resolution
Step 1: Run Simulation
bash
./scenarios/dns-resolution/simulate.shStep 2: Observe
bash
kubectl get pods -n dns-test
kubectl exec dns-test-pod -n dns-test -- nslookup test-serviceStep 3: Diagnose
Try First:
- Test DNS resolution
- Check DNS configuration
- Check CoreDNS
- Review DNS policy
If Stuck:
bash
cat scenarios/dns-resolution/diagnosis.mdStep 4: Resolve
bash
cat scenarios/dns-resolution/resolution.md
# Follow resolution stepsStep 5: Verify
bash
kubectl exec dns-test-pod -n dns-test -- nslookup test-service.dns-test.svc.cluster.localScenario 6: Certificate Issues
Step 1: Run Simulation
bash
./scenarios/certificate-issues/simulate.shStep 2: Observe
bash
kubectl logs cert-test-pod -n cert-test
kubectl exec cert-test-pod -n cert-test -- curl -v https://expired.badssl.comStep 3: Diagnose
Try First:
- Check certificate expiration
- Test certificate validity
- Review error messages
- Check certificate chain
If Stuck:
bash
cat scenarios/certificate-issues/diagnosis.mdStep 4: Resolve
bash
cat scenarios/certificate-issues/resolution.md
# Follow resolution stepsStep 5: Verify
bash
# Test with valid certificate
kubectl exec cert-test-pod -n cert-test -- curl -v https://www.google.comUsing Diagnostic Tools
Connectivity Check
bash
./diagnostic-tools/connectivity-check.sh [namespace] [pod-name]Resource Inspector
bash
./diagnostic-tools/resource-inspector.sh [namespace]Log Collector
bash
./diagnostic-tools/log-collector.sh [namespace] [pod-name] [output-dir]Cluster Health
bash
./diagnostic-tools/cluster-health.shBest Practices
1. Try First, Then Look
Approach:
- Try to diagnose before reading guides
- Use systematic debugging
- Form your own hypotheses
- Learn from mistakes
2. Practice Multiple Times
Repetition:
- Run scenarios multiple times
- Try different approaches
- Build pattern recognition
- Improve speed
3. Document Your Process
Documentation:
- What you observed
- What you tried
- What worked
- What didn't work
4. Build Your Toolkit
Toolkit:
- Favorite commands
- Diagnostic scripts
- Pattern library
- Runbooks
Cleanup
Clean Up Scenarios
bash
./scripts/cleanup-all.shDelete Cluster
bash
kind delete cluster --name troubleshooting-labNext Steps
After completing all scenarios:
- Practice Regularly: Run scenarios to maintain skills
- Build Patterns: Document patterns you recognize
- Share Knowledge: Teach others what you learned
- Apply to Real Issues: Use methodology on real problems
- Continuous Improvement: Keep learning and improving
Related Documentation
Remember: Practice makes perfect. The more you troubleshoot, the better you'll become!