0
0
Kubernetesdevops~30 mins

Deployment as higher-level abstraction in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Deployment as higher-level abstraction in Kubernetes
📖 Scenario: You are managing a simple web application that needs to run reliably on Kubernetes. Instead of creating Pods directly, you will use a Deployment to manage the Pods. This helps Kubernetes keep your app running smoothly even if some Pods fail.
🎯 Goal: Create a Kubernetes Deployment YAML file that runs an NGINX web server with 3 replicas. Then, update the Deployment to change the number of replicas. Finally, display the Deployment status using kubectl commands.
📋 What You'll Learn
Create a Deployment YAML file named nginx-deployment.yaml with 3 replicas
Use the nginx:1.21 image for the container
Add a label app: nginx to the Deployment and Pod template
Update the Deployment to scale replicas from 3 to 5
Use kubectl commands to apply the Deployment and check its status
💡 Why This Matters
🌍 Real World
Deployments are used in real Kubernetes clusters to manage application Pods. They ensure your app stays running and can be updated without downtime.
💼 Career
Understanding Deployments is essential for DevOps engineers and site reliability engineers who manage containerized applications in production.
Progress0 / 4 steps
1
Create the initial Deployment YAML
Create a file named nginx-deployment.yaml with a Deployment that has replicas: 3, uses the container image nginx:1.21, and has the label app: nginx in both metadata and pod template.
Kubernetes
Need a hint?

Remember to set replicas: 3 under spec and add app: nginx labels in both metadata and template.metadata.

2
Add a variable for replicas count
Add a comment at the top of nginx-deployment.yaml defining a variable replicaCount set to 3 to represent the number of replicas.
Kubernetes
Need a hint?

Add a YAML comment at the very top like ## replicaCount: 3 to represent the replicas count.

3
Update replicas count in Deployment
Change the replicas field in nginx-deployment.yaml from 3 to 5 to scale the Deployment.
Kubernetes
Need a hint?

Find the replicas field under spec and change its value to 5.

4
Apply Deployment and check status
Run the command kubectl apply -f nginx-deployment.yaml to create or update the Deployment. Then run kubectl get deployment nginx-deployment to display the Deployment status.
Kubernetes
Need a hint?

Use kubectl apply -f nginx-deployment.yaml to apply the Deployment and kubectl get deployment nginx-deployment to see the status. The output should show 5 replicas ready.