|
| 1 | +# Checkpoint 29 — Kubernetes Deployments |
| 2 | + |
| 3 | +## 🎯 Objective |
| 4 | + |
| 5 | +Understand the purpose of Kubernetes Deployments and how they provide a higher-level way to manage application Pods. |
| 6 | + |
| 7 | +The goal of this checkpoint was to move beyond manually creating individual Pods and understand how Kubernetes uses Deployments and ReplicaSets to manage application workloads. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 📚 Topics Covered |
| 12 | + |
| 13 | +- Deployment Fundamentals |
| 14 | +- Desired State |
| 15 | +- Deployment Manifests |
| 16 | +- Deployment Controllers |
| 17 | +- ReplicaSets |
| 18 | +- Deployment → ReplicaSet → Pod relationship |
| 19 | +- Inspecting Deployments |
| 20 | +- Inspecting ReplicaSets |
| 21 | +- Inspecting Pods managed by a Deployment |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 🤔 Questions Explored |
| 26 | + |
| 27 | +- What problem does a Kubernetes Deployment solve? |
| 28 | +- Why use a Deployment instead of creating a standalone Pod? |
| 29 | +- What is the relationship between a Deployment, ReplicaSet, and Pod? |
| 30 | +- What does "desired state" mean in Kubernetes? |
| 31 | +- How does a Deployment create and manage Pods? |
| 32 | +- What role does a ReplicaSet play? |
| 33 | +- How can we inspect the resources created by a Deployment? |
| 34 | +- Why is the Deployment considered a higher-level Kubernetes abstraction? |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 🔬 Labs and Experiments |
| 39 | + |
| 40 | +### 1. Create a Kubernetes Deployment |
| 41 | + |
| 42 | +Created a Deployment manifest containing: |
| 43 | + |
| 44 | +- Deployment name |
| 45 | +- Pod template |
| 46 | +- Container name |
| 47 | +- Container image |
| 48 | +- Container port |
| 49 | +- Pod labels |
| 50 | +- Replica configuration |
| 51 | + |
| 52 | +Applied the Deployment using: |
| 53 | + |
| 54 | +```bash |
| 55 | +kubectl apply -f deployment.yaml |
| 56 | + |
| 57 | +Kubernetes successfully created the Deployment. |
| 58 | + |
| 59 | +2. Inspect the Deployment |
| 60 | + |
| 61 | +Inspected the Deployment using: |
| 62 | + |
| 63 | +kubectl get deployments |
| 64 | + |
| 65 | +and: |
| 66 | + |
| 67 | +kubectl describe deployment hello-deployment |
| 68 | + |
| 69 | +Observed information including: |
| 70 | + |
| 71 | +Deployment name |
| 72 | +Desired replicas |
| 73 | +Updated replicas |
| 74 | +Available replicas |
| 75 | +Deployment selector |
| 76 | +Pod template |
| 77 | +Container configuration |
| 78 | +ReplicaSet associated with the Deployment |
| 79 | +3. Inspect the ReplicaSet |
| 80 | + |
| 81 | +Used: |
| 82 | + |
| 83 | +kubectl get replicasets |
| 84 | + |
| 85 | +to identify the ReplicaSet created by the Deployment. |
| 86 | + |
| 87 | +The relationship observed was: |
| 88 | + |
| 89 | +Deployment |
| 90 | + | |
| 91 | + v |
| 92 | +ReplicaSet |
| 93 | + | |
| 94 | + v |
| 95 | +Pod |
| 96 | + |
| 97 | +The Deployment acts as the higher-level controller while the ReplicaSet manages the Pods created from the Deployment's Pod template. |
| 98 | +
|
| 99 | +4. Inspect the Pods |
| 100 | +
|
| 101 | +Used: |
| 102 | +
|
| 103 | +kubectl get pods |
| 104 | +
|
| 105 | +to observe the Pods created by the Deployment. |
| 106 | +
|
| 107 | +The generated Pod name demonstrated that the Pod was created and managed through the Deployment and ReplicaSet hierarchy. |
| 108 | +
|
| 109 | +The resulting architecture was: |
| 110 | +
|
| 111 | +Deployment |
| 112 | + | |
| 113 | + v |
| 114 | +ReplicaSet |
| 115 | + | |
| 116 | + v |
| 117 | +Pod |
| 118 | + | |
| 119 | + v |
| 120 | +Container |
| 121 | +🧠 Key Concepts |
| 122 | +Deployment |
| 123 | +
|
| 124 | +A Deployment is a Kubernetes controller used to manage application workloads. |
| 125 | +
|
| 126 | +Instead of manually managing individual Pods, the Deployment describes the desired state of the application. |
| 127 | +
|
| 128 | +For example: |
| 129 | +
|
| 130 | +Application |
| 131 | + | |
| 132 | + v |
| 133 | +Deployment |
| 134 | + | |
| 135 | + v |
| 136 | +ReplicaSet |
| 137 | + | |
| 138 | + v |
| 139 | +Pods |
| 140 | +Desired State |
| 141 | +
|
| 142 | +Kubernetes works by defining the state that the application should have. |
| 143 | +
|
| 144 | +The Deployment describes this desired state through its configuration. |
| 145 | +
|
| 146 | +Conceptually: |
| 147 | +
|
| 148 | +Desired State |
| 149 | + | |
| 150 | + v |
| 151 | +Deployment |
| 152 | + | |
| 153 | + v |
| 154 | +Kubernetes Controllers |
| 155 | + | |
| 156 | + v |
| 157 | +Actual Cluster State |
| 158 | +
|
| 159 | +Kubernetes controllers continuously work toward making the actual cluster state match the desired state. |
| 160 | +
|
| 161 | +ReplicaSet |
| 162 | +
|
| 163 | +A ReplicaSet is responsible for maintaining the desired number of Pods associated with its Pod template. |
| 164 | +
|
| 165 | +The Deployment creates and manages the ReplicaSet. |
| 166 | +
|
| 167 | +Deployment |
| 168 | + | |
| 169 | + v |
| 170 | +ReplicaSet |
| 171 | + | |
| 172 | + v |
| 173 | +Pods |
| 174 | +
|
| 175 | +This separation allows Kubernetes to manage application workloads through controllers rather than requiring the user to manually manage individual Pods. |
| 176 | +
|
| 177 | +Pod Template |
| 178 | +
|
| 179 | +The Deployment contains a Pod template describing how the Pods should be created. |
| 180 | +
|
| 181 | +Example: |
| 182 | +
|
| 183 | +spec: |
| 184 | + template: |
| 185 | + metadata: |
| 186 | + labels: |
| 187 | + app: hello |
| 188 | +
|
| 189 | + spec: |
| 190 | + containers: |
| 191 | + - name: nginx-container |
| 192 | + image: nginx:latest |
| 193 | + ports: |
| 194 | + - containerPort: 80 |
| 195 | +
|
| 196 | +The template becomes the blueprint used when the ReplicaSet creates Pods. |
| 197 | +
|
| 198 | +Resource Hierarchy |
| 199 | +
|
| 200 | +The most important relationship learned in this checkpoint was: |
| 201 | +
|
| 202 | +Deployment |
| 203 | + | |
| 204 | + | manages |
| 205 | + v |
| 206 | +ReplicaSet |
| 207 | + | |
| 208 | + | creates/manages |
| 209 | + v |
| 210 | +Pod |
| 211 | + | |
| 212 | + | runs |
| 213 | + v |
| 214 | +Container |
| 215 | +
|
| 216 | +Each layer has a different responsibility. |
| 217 | +
|
| 218 | +🧪 Validation |
| 219 | +
|
| 220 | +The Deployment was successfully created and inspected using: |
| 221 | +
|
| 222 | +kubectl apply -f deployment.yaml |
| 223 | +kubectl get deployments |
| 224 | +kubectl describe deployment hello-deployment |
| 225 | +kubectl get replicasets |
| 226 | +kubectl get pods |
| 227 | +
|
| 228 | +The resulting resources confirmed that Kubernetes created the expected Deployment, ReplicaSet, and Pod hierarchy. |
| 229 | +
|
| 230 | +🧩 Mental Model |
| 231 | +
|
| 232 | +The main mental model from this checkpoint is: |
| 233 | +
|
| 234 | + Desired Application State |
| 235 | + | |
| 236 | + v |
| 237 | + Deployment |
| 238 | + | |
| 239 | + v |
| 240 | + ReplicaSet |
| 241 | + | |
| 242 | + v |
| 243 | + Pod |
| 244 | + | |
| 245 | + v |
| 246 | + Container |
| 247 | +
|
| 248 | +Instead of thinking: |
| 249 | +
|
| 250 | +"I need to manually create a container." |
| 251 | +
|
| 252 | +Kubernetes encourages thinking: |
| 253 | +
|
| 254 | +"This is the state I want my application to have." |
| 255 | +
|
| 256 | +The Kubernetes controllers then work toward maintaining that state. |
| 257 | +
|
| 258 | +💭 Reflection |
| 259 | +
|
| 260 | +This checkpoint was my first deeper look into Kubernetes controllers. |
| 261 | +
|
| 262 | +Before working with Deployments, I mainly thought of a Pod as the unit that runs my application. |
| 263 | +
|
| 264 | +After this checkpoint, I understood that Pods are only one layer of the Kubernetes workload model. |
| 265 | +
|
| 266 | +The Deployment provides the desired application configuration, while the ReplicaSet manages the Pods created from that configuration. |
| 267 | +
|
| 268 | +The relationship became much clearer after inspecting the resources directly: |
| 269 | +
|
| 270 | +Deployment |
| 271 | + ↓ |
| 272 | +ReplicaSet |
| 273 | + ↓ |
| 274 | +Pod |
| 275 | + ↓ |
| 276 | +Container |
| 277 | +
|
| 278 | +This also helped me understand why Kubernetes is more than simply running containers. It provides a control system that manages the desired state of applications. |
| 279 | +
|
| 280 | +📌 Checkpoint Status |
| 281 | + Deployment Fundamentals |
| 282 | + Desired State |
| 283 | + Deployment Manifest |
| 284 | + ReplicaSets |
| 285 | + Deployment → ReplicaSet → Pod relationship |
| 286 | + Inspect Deployments |
| 287 | + Inspect ReplicaSets |
| 288 | + Inspect Pods |
| 289 | +🚀 Next Checkpoint |
| 290 | +Checkpoint 30 — Kubernetes Scaling Deployments |
| 291 | +
|
| 292 | +Next, I will explore how Kubernetes Deployments can scale applications by changing the desired number of replicas. |
| 293 | +
|
| 294 | +Topics will include: |
| 295 | +
|
| 296 | +Scaling Deployments |
| 297 | +Replica counts |
| 298 | +Desired vs actual state |
| 299 | +Creating additional Pods |
| 300 | +Observing ReplicaSet behavior during scaling |
| 301 | +``` |
0 commit comments