Rolling updates:
suppose one the updates resulted in some error and we would like to roll back the changes.
or may want to pause the environment, make the changes and resume so that the changes are rolled out together
How do we create a deployment file
everything will be same as replicaset in the yml file except that the kind now will be Deployment
commands
kubectl create -f deployment-ymlFile
kubectl get deployments
kubectl get replicaset (deployment automatically creates replicaset)
kubectl get pods
to see all the created objects at once
kubectl get all
in most of the cases we will not be creating pod definition or replica set file and would be directly creating the deployment file
Rollout and versioning in deployment
when we create a deployment it triggers a rollout, a new rollout creates a new deployment revision.
When container version is updated, a new rollour is triggerd and a new deployment revision is created named revision2.
This helps us keep track of changes made to our deployment and enables us to roll back to previous version of the deployment if required.
we can see the rollout status by
kubectl rolllout status deployment/<name of the deployment>
to see the history and revision of rollout
kubectl rollout history deplyment/<name of deployment>
(this is not the default )
2. Rolling Update
in this, we take down the existing once one by one. This way the system never goes down and the upgrade is seamless.
How to apply the changes
Kubectl apply
kubectl apply -f deployment-definition
by setting image
kubectl set image deployment/myapp-dep \nginx= nginx:1.9.1
the only problem is that doing it this way will result in the deployment file having a different definition
to see the history of deployment we can use, in this we can find the strategy used
kubectl describe deployment
undo update
kubectl rollout undo deployment/myapp-deployment
perform deplyment only with image name and no definition file
kubectl run nginx --image=nginx
summary of deployment commands
create
kubectl create -f deployment deployment-definition.yml
get
kubectl get deployments
update
kubectl apply -f deployment-definition.yml
kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
status
kubectl rollout status deployment/myapp-deployment
kubectl rollout history deployment/myapp-deployment
rollback
kubectl rollout undo deployment/myapp-deployment
in the history command if you want to see the CHANGE-CAUSE , for this we will have to issue a record command when we create cluster
eg.
kubectl create -f deployment-definition.yml --record
suppose one the updates resulted in some error and we would like to roll back the changes.
or may want to pause the environment, make the changes and resume so that the changes are rolled out together
How do we create a deployment file
everything will be same as replicaset in the yml file except that the kind now will be Deployment
commands
kubectl create -f deployment-ymlFile
kubectl get deployments
kubectl get replicaset (deployment automatically creates replicaset)
kubectl get pods
to see all the created objects at once
kubectl get all
apiVersion: apps/v1 kind: Deployment metadata: name: myapp-deployment labels: name: myapp type: front-end spec: template: metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-controller image: nginx replicas: 3 selector: matchLabels: type: front-end
in most of the cases we will not be creating pod definition or replica set file and would be directly creating the deployment file
Rollout and versioning in deployment
when we create a deployment it triggers a rollout, a new rollout creates a new deployment revision.
When container version is updated, a new rollour is triggerd and a new deployment revision is created named revision2.
This helps us keep track of changes made to our deployment and enables us to roll back to previous version of the deployment if required.
we can see the rollout status by
kubectl rolllout status deployment/<name of the deployment>
to see the history and revision of rollout
kubectl rollout history deplyment/<name of deployment>
Deployment strategy
1. Recreate strategy
delete all the existing once and deploy the new one
problem: system will inaccessible to users the while the system is down(this is not the default )
2. Rolling Update
in this, we take down the existing once one by one. This way the system never goes down and the upgrade is seamless.
How to apply the changes
Kubectl apply
kubectl apply -f deployment-definition
by setting image
kubectl set image deployment/myapp-dep \nginx= nginx:1.9.1
the only problem is that doing it this way will result in the deployment file having a different definition
to see the history of deployment we can use, in this we can find the strategy used
kubectl describe deployment
undo update
kubectl rollout undo deployment/myapp-deployment
perform deplyment only with image name and no definition file
kubectl run nginx --image=nginx
summary of deployment commands
create
kubectl create -f deployment deployment-definition.yml
get
kubectl get deployments
update
kubectl apply -f deployment-definition.yml
kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
status
kubectl rollout status deployment/myapp-deployment
kubectl rollout history deployment/myapp-deployment
rollback
kubectl rollout undo deployment/myapp-deployment
in the history command if you want to see the CHANGE-CAUSE , for this we will have to issue a record command when we create cluster
eg.
kubectl create -f deployment-definition.yml --record
Comments
Post a Comment