0
0
Kubernetesdevops~30 mins

Scaling Deployments in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Scaling Deployments in Kubernetes
📖 Scenario: You are managing a web application running on Kubernetes. The application needs to handle more users during peak hours. To do this, you will learn how to scale the number of pods in a deployment.
🎯 Goal: Learn how to create a Kubernetes deployment and scale it up by increasing the number of pods.
📋 What You'll Learn
Create a deployment YAML file with a specific name and image
Add a replicas field to set the number of pods
Use kubectl commands to apply the deployment and scale it
Verify the number of pods running matches the desired count
💡 Why This Matters
🌍 Real World
Scaling deployments is essential to handle varying user loads in real applications. It helps maintain performance and availability.
💼 Career
Kubernetes deployment scaling is a fundamental skill for DevOps engineers and site reliability engineers managing cloud-native applications.
Progress0 / 4 steps
1
Create a Deployment YAML file
Create a file named deployment.yaml with a Kubernetes deployment named webapp using the image nginx:1.21. Set the initial number of replicas to 1. Include the required fields: apiVersion, kind, metadata, and spec with replicas and template containing containers with the image.
Kubernetes
Need a hint?

Remember to include replicas: 1 under spec and set the container image to nginx:1.21.

2
Apply the Deployment and Check Pods
Use the command kubectl apply -f deployment.yaml to create the deployment. Then use kubectl get pods -l app=webapp to list the pods with the label app=webapp. Write the exact commands below.
Kubernetes
Need a hint?

Use kubectl apply -f deployment.yaml to create the deployment and kubectl get pods -l app=webapp to see the pods.

3
Scale the Deployment to 3 Replicas
Update the deployment.yaml file to set replicas to 3. Then use the command kubectl apply -f deployment.yaml again to apply the change.
Kubernetes
Need a hint?

Change the replicas field to 3 and apply the deployment again.

4
Verify the Number of Pods Running
Run the command kubectl get pods -l app=webapp --no-headers | wc -l to count the number of pods running with label app=webapp. Then print the number using echo in the format: Pods running: 3.
Kubernetes
Need a hint?

Use command substitution to count pods and then print with echo.