|
| 1 | +# Checkpoint 30 — Kubernetes Scaling Deployments |
| 2 | + |
| 3 | +## 🎯 Objective |
| 4 | + |
| 5 | +Learn how Kubernetes automatically maintains the desired number of Pods using Deployments and ReplicaSets. Practice scaling applications horizontally and observe how Kubernetes creates additional Pods to match the desired state. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 📚 Topics Covered |
| 10 | + |
| 11 | +- Deployment scaling |
| 12 | +- Horizontal scaling |
| 13 | +- ReplicaSets |
| 14 | +- Desired state vs Current state |
| 15 | +- `kubectl scale` |
| 16 | +- Observing Pods with `kubectl get pods -w` |
| 17 | +- Deployment status |
| 18 | +- ReplicaSet status |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## 🤔 Questions Explored |
| 23 | + |
| 24 | +- What happens when a Deployment is scaled? |
| 25 | +- Who actually creates new Pods? |
| 26 | +- What is the relationship between Deployments and ReplicaSets? |
| 27 | +- What does `READY`, `DESIRED`, `CURRENT`, and `AVAILABLE` mean? |
| 28 | +- Why is Kubernetes called a declarative system? |
| 29 | +- Why is horizontal scaling important? |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## 🔬 Labs and Experiments |
| 34 | + |
| 35 | +- Created a Deployment running an Nginx container. |
| 36 | +- Scaled the Deployment from 1 replica to 3 replicas. |
| 37 | + |
| 38 | +```bash |
| 39 | +kubectl scale deployment hello-deployment --replicas=3 |
| 40 | +``` |
| 41 | + |
| 42 | +- Observed Kubernetes create new Pods automatically. |
| 43 | + |
| 44 | +```bash |
| 45 | +kubectl get pods -w |
| 46 | +``` |
| 47 | + |
| 48 | +- Verified Deployment status. |
| 49 | + |
| 50 | +```bash |
| 51 | +kubectl get deployments |
| 52 | +``` |
| 53 | + |
| 54 | +- Verified ReplicaSet status. |
| 55 | + |
| 56 | +```bash |
| 57 | +kubectl get replicasets |
| 58 | +``` |
| 59 | + |
| 60 | +- Confirmed that the Deployment, ReplicaSet, and Pods all reflected the desired state of 3 replicas. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## 🧠 Key Concepts |
| 65 | + |
| 66 | +- A Deployment manages ReplicaSets. |
| 67 | +- A ReplicaSet manages Pods. |
| 68 | +- Scaling a Deployment changes the desired number of replicas. |
| 69 | +- ReplicaSets compare the desired state with the current state. |
| 70 | +- If replicas are missing, ReplicaSets create new Pods. |
| 71 | +- Kubernetes continuously reconciles the cluster to match the declared desired state. |
| 72 | +- Horizontal scaling increases the number of Pods instead of increasing server resources. |
| 73 | + |
| 74 | +Deployment hierarchy: |
| 75 | + |
| 76 | +``` |
| 77 | +
|
| 78 | +Deployment |
| 79 | +↓ |
| 80 | +ReplicaSet |
| 81 | +↓ |
| 82 | +Pods |
| 83 | +↓ |
| 84 | +Containers |
| 85 | +
|
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 💭 Reflection |
| 91 | + |
| 92 | +This checkpoint made Kubernetes feel much more powerful than simply running containers. Instead of manually creating additional containers, I only declared the desired number of replicas and Kubernetes handled everything automatically. I also understood that Deployments never create Pods directly—they delegate that responsibility to ReplicaSets, which continuously reconcile the actual cluster state with the desired state. |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## 🚀 Next Checkpoint |
| 97 | + |
| 98 | +- Kubernetes Services |
| 99 | +- Labels and Selectors |
| 100 | +- ClusterIP |
| 101 | +- NodePort |
| 102 | +- LoadBalancer |
| 103 | +- Pod Networking |
0 commit comments