title | description |
---|---|
Kubernetes - Deployment |
Learn and Implement Kubernetes Deployment |
- 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)
- What is a Deployment?
- What all we can do using Deployment?
- Create a Deployment
- Scale the Deployment
- Expose the Deployment as a Service
- 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
- 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
- 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
- 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
# Access Application
http://<External-IP-from-get-service-output>
curl http://<External-IP-from-get-service-output>