Skip to content

Files

Latest commit

 

History

History

08-kubectl-imperative-k8s-deployment-CREATE

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
title description
Kubernetes - Deployment
Learn and Implement Kubernetes Deployment

Kubernetes Deployment - Topics

  1. Create Deployment
  2. Scale the Deployment
  3. Expose Deployment as a Service
  4. Update Deployment
  5. Rollback Deployment
  6. Rolling Restarts
  7. Pause & Resume Deployments
  8. 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
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
# Access Application
http://<External-IP-from-get-service-output>
curl http://<External-IP-from-get-service-output>