π The Role of Kubernetes in DevOps β A Real-Time Use Case
If you are new to DevOps, you may have heard people talk about Kubernetes. But what exactly is Kubernetes? And why is it so important in the DevOps world?
Letβs break it down in a simple way and explore a Kubernetes DevOps usecase through a real-world example to understand how it works in action.
π§© What is Kubernetes?
- Running applications in containers
- Scaling applications up or down
- Automatically restarting if an app crashes
- Balancing traffic so no server is overloaded
π§ͺ Why Do DevOps Teams Use Kubernetes?
- Automating deployment and scaling
- Making applications easier to move across environments (dev, test, prod)
- Reducing downtime with self-healing
- Managing microservices effectively
π Real-Time Use Case β Deploying a Web App with Kubernetes
Letβs take an example to understand the real-time use of Kubernetes in a DevOps setup.
Scenario: A Company Deploys an E-Commerce Website
1. Containerizing the Application
product-service:1.0
cart-service:1.0
payment-service:1.0
2. Creating a Kubernetes Cluster
3. Deploying the Application Using YAML
To tell Kubernetes what to deploy and how, we use a configuration file written in YAML.
Here is an example YAML file to deploy the Product Service:
apiVersion: apps/v1
kind: Deployment
metadata:
Β Β Β Β name: product-deployment
spec:
Β Β Β Β replicas: 3
Β Β Β Β selector:
Β Β Β Β Β Β matchLabels:
Β Β Β Β Β Β Β Β Β Β app: product
Β Β Β Β template:
Β Β Β Β Β Β Β metadata:
Β Β Β Β Β Β Β Β Β Β labels:
Β Β Β Β Β Β Β Β Β Β Β Β app: product
Β Β Β Β Β Β Β spec:
Β Β Β Β Β Β Β Β Β Β Β containers:
Β Β Β Β Β Β Β Β Β Β Β – name: product
Β Β Β Β Β Β Β Β Β Β Β Β image: shopkart/product-service:1.0
Β Β Β Β Β Β Β Β Β Β Β Β ports:
Β Β Β Β Β Β Β Β Β Β Β Β – containerPort: 8080
π§Ύ Letβs break it down:
Β Β Β Β Β Β Β Β Β Β Β Section | Explanation |
apiVersion: apps/v1 | This defines which version of the Kubernetes API we are using for the deployment. |
kind: Deployment | We are creating a Deployment β which helps manage a set of identical pods. |
metadata: | Information like the name of the deployment (product-deployment). |
replicas: 3 | We want 3 instances (pods) of the product microservice running. |
selector: | Tells Kubernetes how to find the pods related to this deployment using labels. |
template: | The actual configuration of the pods (like a template for them). |
containers: | Inside the pod, we define a container: |
– name: product | The containerβs name. |
image: shopkart/product-service:1.0 | The Docker image to run inside this container. |
ports: | Exposes port 8080, which the app will use inside the container. |
This YAML file helps automate the deployment of your app with just one command:
kubectl apply -f product-deployment.yaml
4. Service and Load Balancing
To make the app accessible, Kubernetes uses a Service object, which routes traffic to the correct pods and balances the load.
5. Rolling Updates and Rollbacks
product-service:2.0
is ready, the DevOps team updates the image in the YAML and reapplies it. Kubernetes will roll out the update slowly, checking if everything works.6. Auto-Scaling & Self-Healing
- If user traffic increases (like during a festival sale), Kubernetes can add more pods automatically.
- If a pod crashes, Kubernetes restores it immediately.
π‘ Summary β Why Kubernetes is a DevOps Hero
Feature | Benefit |
---|---|
YAML Configuration | Defines app setup in a readable way |
Container Orchestration | Runs and manages containers automatically |
Auto-Scaling | Adjusts resources based on traffic |
Rolling Updates | No downtime during new releases |
Self-Healing | Recovers from crashes without human helpy |
Portability | Works across cloud or on-prem |
π§ Final Thoughts
- Docker (to create containers)
- Kubernetes YAML (to manage them)
- Use Minikube to practice locally
Devops Multi cloud Training
Choose the training style that fits your schedule β Self-Paced or Live Interactive Sessions. Both include hands-on projects, expert support, and lifetime access.
Feature | Self-Paced Training | Live Training |
---|---|---|
π― Mode | π₯Pre-Recorded Session | π§βπ«Live Class + Recordings |
πΌ Projects | π Weekend Real-Time Projects | π Weekdays + Weekend Real-Time Projects |
β Doubt Clearing | π Weekend Live Support Session | π§ Anytime Doubt Clearing Session |
π₯ Career Support & Mentorship | β No | β Yes |
π Global Certification Training | β No | β Yes |
π Access | βΎοΈ Lifetime Access | βΎοΈ Lifetime Access |
π° Fees | βΉ4,999 (2 x βΉ2,500) | βΉ7,999 (2 x βΉ4,000) |
βΉοΈ For More Info | Explore Self-Paced Training | Explore Live Training |