Shashikant shah

Tuesday, 15 December 2020

What is a deployment in Kubernetes Part-08

 What is a deployment in kubernetes ?

1.Deployment can scale up/Down replicas of Pods.
2.multiple replicas.
3.Upgrade/Rollout.
4.Rollback.
5.pause and resume.

Deployment Strategies types :-

1.Recreate :- In this type of very simple deployment, all of the old pods are killed all at once and get replaced all at once with the new ones.


2.RollingUpdate ( Ramped or Incremental ) :-

The rolling deployment is the standard default deployment to Kubernetes. It works by slowly, one by one, replacing pods of the previous version of your application with pods of the new version without any cluster downtime.


3.Canary :-

10 instances, first 2 instance deployed new version & test is done then new version deployed on 8 instances. Full deployment has been done, after that old version instance will be deleted.

 

4.blue / Green :-

In a blue/green deployment strategy (sometimes referred to as red/black) the old version of the application (green) and the new version (blue) get deployed at the same time. When both of these are deployed, users only have access to the green; whereas, the blue is available to your QA team for test automation on a separate service or via direct port-forwarding.












1.Deployments – Manifest file.


2.Deployments – Create and Display.

# kubectl create -f nginx-deploy.yaml

# kubectl get deploy -o wide



# kubectl get rs -o wide (deployment has been generate selector & label pod-template-hash=5878ddd45b)




# kubectl get pods --show-labels (deployment has been generate selector & label pod-template-hash=5878ddd45b)




3.Desployments – Describe



 

4.Update nginx:1.7.9 -> nginx:1.9.1

If any changes in pods like images then trigger rollout.









5.uses maxSurge and maxUnavailable in RollingUpdate strategy.

maxSurge :- deployment time how many new pods running, mention like 25% and number of pods.

maxUnavailable :- deployment time how many old pods shutdown, mention like 25% and number of pods.






















Add maxSurge
























When deployment is there, 25% will be unavailable pods, and 25% will be new pods.


6.How to Rollback deployment.

i) store to comment use --record.

history comments By default its store 10, if increase limit Add "revisionHistoryLimit: 20" under "spec" in yaml file. 

# kubectl apply -f nginx-deploy.yaml --record

# kubectl rollout history deploy nginx-deploy

deployment "nginx-deploy" successfully rolled out

# kubectl rollout status deploy nginx-deploy






OR
ii) Deployment comment line add in yaml file :-

# vim nginx-deploy.yaml file
 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deploy
  labels:
    app: nginx-app
  annotations:
    kubernetes.io/change-cause: "nginx:1.7.9 deployed"
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-app
 
#  kubectl apply -f nginx-deploy.yaml
 
# kubectl rollout history deploy nginx-deploy








7. How to Undo (Rollback) process.

Nginx:1.9.1 -> Nginx:1.7.9

# kubectl rollout history deploy nginx-deploy






i) Need to previous version using undo command.

# kubectl rollout undo deployment nginx-deploy


 




ii) using undo command with Revision no.

# kubectl rollout undo --help

# kubectl rollout undo --to-revision=2 deploy nginx-deploy

iii) Pause and Resume deployment:-

 # kubectl rollout pause deployment nginx-deploy

# kubectl rollout resume deployment nginx-deploy

6. Deployment Scale Up/Down & Delete.


















# Delete deployment.



No comments:

Post a Comment