Advanced CKAD Topic: Master the art of risk-free application deployments using native Kubernetes primitives
Canary deployments are a sophisticated deployment strategy that allows you to gradually roll out new application versions while minimizing risk and maintaining system stability. This comprehensive guide covers everything from basic concepts to production-ready implementations.
After completing this module, you will be able to:
✅ Understand deployment strategies: Blue-green vs Canary patterns
✅ Implement canary deployments: Using native Kubernetes resources
✅ Manage traffic distribution: Progressive rollout strategies
✅ Monitor deployments: Health checks and observability
✅ Handle rollbacks: Safe fallback procedures
✅ Automate processes: CI/CD integration patterns
End Users → Load Balancer → Service → Pods (v1 + v2)
↗ ↘
ReplicaSet ReplicaSet
↑ ↑
Deployment Deployment
(v1) (v2)
# Verify cluster access
kubectl cluster-info
# Create namespace
kubectl create namespace canary-demo
# Verify kubectl version
kubectl version --client
# Clone and navigate
git clone https://github.com/Salwan-Mohamed/CKAD-journey.git
cd CKAD-journey/Master-Canary-Deployments
# Deploy v1
kubectl apply -f examples/v1-deployment.yaml
kubectl apply -f examples/service-v1.yaml
# Verify v1 is running
kubectl get pods -n canary-demo
# Deploy v2 (canary)
kubectl apply -f examples/v2-deployment.yaml
# Start canary traffic
kubectl apply -f examples/service-canary.yaml
# Monitor traffic distribution
kubectl run client --image=busybox --rm -it -- sh
# Inside pod: while true; do wget -qO- http://webapp-service.canary-demo.svc.cluster.local; sleep 1; done
| Phase | V1 Pods | V2 Pods | V1 Traffic | V2 Traffic | Action |
|---|---|---|---|---|---|
| Initial | 3 | 0 | 100% | 0% | Stable v1 |
| Deploy v2 | 3 | 1 | 100% | 0% | v2 deployed, no traffic |
| Start Canary | 3 | 1 | 75% | 25% | Begin testing |
| Increase Canary | 3 | 3 | 50% | 50% | Scale up v2 |
| Reduce Legacy | 1 | 3 | 25% | 75% | Scale down v1 |
| Complete Migration | 0 | 3 | 0% | 100% | Full cutover |
This topic covers multiple CKAD exam domains:
| Aspect | Canary Deployment | Blue-Green Deployment |
|---|---|---|
| Traffic Shift | Gradual (5%→25%→50%→100%) | Instant (0%→100%) |
| Risk Level | Lower | Higher |
| Resource Usage | Efficient | Requires 2x resources |
| Rollback Speed | Gradual | Instant |
| Monitoring Time | Extended | Limited |
# Generic label (consistent across versions)
app-name: webapp
# Version-specific labels
app-version: v1.0 # for version 1
app-version: v2.0 # for version 2
Found an issue or want to improve the content?
🚀 Ready to master canary deployments? Start with the Complete Guide!
Last updated: December 2024