Hands-On Exercises
Application: [Application Name]
Purpose: Practice operational tasks in a safe environment
Exercise Environment
Prerequisites
- Access to training cluster
kubectlconfigured- Access to Grafana
- Access to application
Safety
- All exercises use test/development environment
- No production data at risk
- Rollback procedures available
- Trainer supervision
Exercise 1: System Exploration
Objective: Familiarize with the system and basic operations
Duration: 45 minutes
Tasks
Access Cluster
bash# Verify cluster access kubectl cluster-info # List all namespaces kubectl get namespacesExplore Application Namespace
bash# List all resources in namespace kubectl get all -n [namespace-name] # Get detailed information kubectl describe namespace [namespace-name]Examine Pods
bash# List pods kubectl get pods -n [namespace-name] -o wide # Describe a pod kubectl describe pod [pod-name] -n [namespace-name] # View pod logs kubectl logs [pod-name] -n [namespace-name]Examine Services
bash# List services kubectl get svc -n [namespace-name] # Describe a service kubectl describe svc [service-name] -n [namespace-name] # Get service endpoints kubectl get endpoints [service-name] -n [namespace-name]Examine Configuration
bash# List ConfigMaps kubectl get configmap -n [namespace-name] # View ConfigMap kubectl get configmap [config-name] -n [namespace-name] -o yaml # List Secrets kubectl get secret -n [namespace-name]
Verification
- [ ] Can access cluster
- [ ] Can list resources
- [ ] Can view pod details
- [ ] Can view logs
- [ ] Understand resource relationships
Exercise 2: Monitoring and Dashboards
Objective: Learn to monitor system health
Duration: 60 minutes
Tasks
Access Grafana
- Open Grafana URL
- Login with credentials
- Navigate dashboards
Cluster Overview Dashboard
- Review cluster metrics
- Identify CPU usage
- Identify memory usage
- Check pod status
- Check node status
Application Dashboard
- Review application metrics
- Check request rates
- Check error rates
- Review response times
Create Custom Query
- Access Prometheus
- Write query for pod CPU usage
- Write query for error rate
- Create simple dashboard
Review Alerts
- View active alerts
- Understand alert conditions
- Check alert history
Verification
- [ ] Can access Grafana
- [ ] Can navigate dashboards
- [ ] Can interpret metrics
- [ ] Can create queries
- [ ] Understand alerts
Exercise 3: Troubleshooting
Objective: Practice troubleshooting common issues
Duration: 60 minutes
Scenario 1: Pod Not Starting
Setup: Trainer creates pod with configuration error
Tasks:
Identify pod issue
bashkubectl get pods -n [namespace-name] kubectl describe pod [pod-name] -n [namespace-name]Check events
bashkubectl get events -n [namespace-name] --sort-by='.lastTimestamp'Check logs
bashkubectl logs [pod-name] -n [namespace-name]Resolve issue
- Identify root cause
- Fix configuration
- Verify pod starts
Scenario 2: High CPU Usage
Setup: Trainer creates high CPU load
Tasks:
Identify high CPU usage
bashkubectl top pods -n [namespace-name]Investigate cause
bashkubectl logs [pod-name] -n [namespace-name] kubectl exec [pod-name] -n [namespace-name] -- topResolve issue
- Identify resource-intensive process
- Scale deployment
- Or optimize application
Scenario 3: Application Errors
Setup: Trainer introduces application error
Tasks:
Identify errors
- Check application logs
- Check Grafana dashboards
- Review error rates
Investigate
- Analyze error messages
- Check recent changes
- Review configuration
Resolve
- Fix configuration
- Or rollback deployment
Verification
- [ ] Can identify pod issues
- [ ] Can analyze logs
- [ ] Can resolve common issues
- [ ] Understand troubleshooting process
Exercise 4: Deployment
Objective: Practice deployment procedures
Duration: 60 minutes
Tasks
Pre-Deployment Checklist
- Review deployment runbook
- Verify cluster access
- Check current deployment
- Backup configuration
Perform Deployment
bash# Update image kubectl set image deployment/[deployment-name] \ [container-name]=[new-image]:[version] \ -n [namespace-name] # Watch rollout kubectl rollout status deployment/[deployment-name] -n [namespace-name]Monitor Deployment
bash# Watch pods kubectl get pods -n [namespace-name] -w # Check logs kubectl logs -f deployment/[deployment-name] -n [namespace-name]Verify Deployment
- Check pod status
- Test health endpoint
- Verify functionality
- Check metrics
Practice Rollback
bash# Rollback deployment kubectl rollout undo deployment/[deployment-name] -n [namespace-name] # Verify rollback kubectl rollout status deployment/[deployment-name] -n [namespace-name]
Verification
- [ ] Can perform deployment
- [ ] Can monitor rollout
- [ ] Can verify deployment
- [ ] Can rollback if needed
Exercise 5: Scaling
Objective: Practice scaling operations
Duration: 45 minutes
Tasks
Monitor Current State
bash# Check current replicas kubectl get deployment [deployment-name] -n [namespace-name] # Check resource usage kubectl top pods -n [namespace-name] # Check metrics in GrafanaScale Up
bash# Scale deployment kubectl scale deployment/[deployment-name] --replicas=[count] -n [namespace-name] # Watch scaling kubectl get pods -n [namespace-name] -wVerify Scaling
- Check new pods are running
- Verify load distribution
- Check metrics
Scale Down
bash# Scale down kubectl scale deployment/[deployment-name] --replicas=[count] -n [namespace-name]Configure Autoscaling (Optional)
bash# Create HPA kubectl apply -f hpa.yaml # Monitor HPA kubectl get hpa -n [namespace-name] -w
Verification
- [ ] Can scale deployment
- [ ] Can verify scaling
- [ ] Understand autoscaling
- [ ] Can monitor scaling
Exercise 6: Incident Response
Objective: Practice incident response procedures
Duration: 60 minutes
Scenario: Pod Crash Loop
Setup: Trainer creates crash looping pod
Tasks
Detect Incident
- Check monitoring alerts
- Review dashboards
- Identify issue
Triage
bash# Check pod status kubectl get pods -n [namespace-name] # Check pod events kubectl describe pod [pod-name] -n [namespace-name] # Check logs kubectl logs [pod-name] -n [namespace-name] --previousInvestigate
- Analyze error messages
- Check configuration
- Review recent changes
Resolve
- Fix configuration
- Restart pod
- Or rollback deployment
Document
- Document incident
- Document resolution
- Update runbook if needed
Verification
- [ ] Can detect incidents
- [ ] Can triage issues
- [ ] Can investigate root cause
- [ ] Can resolve incidents
- [ ] Can document incidents
Exercise 7: Backup and Restore
Objective: Practice backup and restore procedures
Duration: 60 minutes
Tasks
Perform Backup
bash# Backup configuration kubectl get all -n [namespace-name] -o yaml > backup-$(date +%Y%m%d).yaml # Backup database (if applicable) kubectl exec -n [namespace-name] [db-pod] -- \ pg_dump -U [user] [database] > backup-db-$(date +%Y%m%d).sqlVerify Backup
- Check backup files exist
- Verify backup file size
- Test backup readability
Simulate Data Loss
- Delete test resource
- Or corrupt test data
Perform Restore
bash# Restore configuration kubectl apply -f backup-YYYYMMDD.yaml # Restore database (if applicable) kubectl exec -i -n [namespace-name] [db-pod] -- \ psql -U [user] [database] < backup-db-YYYYMMDD.sqlVerify Restore
- Verify resources restored
- Test functionality
- Verify data integrity
Verification
- [ ] Can perform backup
- [ ] Can verify backup
- [ ] Can perform restore
- [ ] Can verify restore
Exercise 8: Upgrade
Objective: Practice upgrade procedures
Duration: 60 minutes
Tasks
Pre-Upgrade Preparation
- Review upgrade runbook
- Backup current deployment
- Review release notes
- Check compatibility
Perform Upgrade
bash# Upgrade deployment kubectl set image deployment/[deployment-name] \ [container-name]=[new-image]:[new-version] \ -n [namespace-name] # Watch rollout kubectl rollout status deployment/[deployment-name] -n [namespace-name]Monitor Upgrade
- Watch pods
- Check logs
- Monitor metrics
Verify Upgrade
- Check pod status
- Test functionality
- Verify metrics
Practice Rollback
bash# Rollback if needed kubectl rollout undo deployment/[deployment-name] -n [namespace-name]
Verification
- [ ] Can perform upgrade
- [ ] Can monitor upgrade
- [ ] Can verify upgrade
- [ ] Can rollback if needed
Exercise Completion
Self-Assessment
After completing exercises, assess:
- [ ] Comfortable with basic operations
- [ ] Can monitor system health
- [ ] Can troubleshoot common issues
- [ ] Can perform deployments
- [ ] Can scale system
- [ ] Can respond to incidents
- [ ] Can backup and restore
- [ ] Can perform upgrades
Areas for Improvement
Document areas needing more practice:
- [ ] List areas for improvement
- [ ] Schedule additional practice
- [ ] Review documentation
- [ ] Ask questions
Remember: Practice makes perfect. Repeat exercises until comfortable.