Kubernetes - Deployment
Kubernetes Deployment - Topics¶
- Create Deployment
- Scale the Deployment
- Expose Deployment as a Service
- Update Deployment
- Rollback Deployment
- Rolling Restarts
- Pause & Resume Deployments
- Canary Deployments (Will be covered at Declarative section of Deployments)
Step-01: Introduction to Deployments¶
- What is a Deployment?
- What all we can do using Deployment?
- Create a Deployment
- Scale the Deployment
- Expose the Deployment as a Service
Step-02: Create Deployment¶
- Create Deployment to rollout a ReplicaSet
- Verify Deployment, ReplicaSet & Pods
- Docker Image Location: https://hub.docker.com/repository/docker/stacksimplify/kubenginx
# Create Deployment kubectl create deployment <Deplyment-Name> --image=<Container-Image> kubectl create deployment my-first-deployment --image=stacksimplify/kubenginx:1.0.0 # Verify Deployment kubectl get deployments kubectl get deploy # Describe Deployment kubectl describe deployment <deployment-name> kubectl describe deployment my-first-deployment # Verify ReplicaSet kubectl get rs # Verify Pod kubectl get po
Update Change-Cause for the Kubernetes Deployment - Rollout History¶
- Observation: We have the rollout history, so we can switch back to older revisions using revision history available to us
# Verify Rollout History kubectl rollout history deployment/my-first-deployment # Update REVISION CHANGE-CAUSE for Kubernetes Deployment kubectl annotate deployment/my-first-deployment kubernetes.io/change-cause="Deployment CREATE - App Version 1.0.0" # Verify Rollout History kubectl rollout history deployment/my-first-deployment
Step-03: Scaling a Deployment¶
- Scale the deployment to increase the number of replicas (pods)
# Scale Up the Deployment kubectl scale --replicas=10 deployment/<Deployment-Name> kubectl scale --replicas=10 deployment/my-first-deployment # Verify Deployment kubectl get deploy # Verify ReplicaSet kubectl get rs # Verify Pods kubectl get po # Scale Down the Deployment kubectl scale --replicas=2 deployment/my-first-deployment kubectl get deploy
Step-04: Expose Deployment as a Service¶
- Expose Deployment with a service (LoadBalancer Service) to access the application externally (from internet)
# Expose Deployment as a Service kubectl expose deployment <Deployment-Name> --type=LoadBalancer --port=80 --target-port=80 --name=<Service-Name-To-Be-Created> kubectl expose deployment my-first-deployment --type=LoadBalancer --port=80 --target-port=80 --name=my-first-deployment-service # Get Service Info kubectl get svc - Access the Application using Public IP
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
DEVOPS2026FEB
Enroll Now on Udemy
🎉 Offer