Both sides previous revision Previous revision Next revision | Previous revision |
k8s_basic_deployments [2020/05/03 12:04] – andonovj | k8s_basic_deployments [2020/05/03 12:16] (current) – andonovj |
---|
| |
</Code> | </Code> |
| |
| =====Rolling Back===== |
| Now, before we continue, let's speak a little bit about Change History. We can check the history of all changes as follows: |
| |
| <Code: bash| Check Change History> |
| ubuntu@k8s-master:~$ kubectl rollout history deploy hello-deploy |
| deployment.apps/hello-deploy |
| REVISION CHANGE-CAUSE |
| 1 <none> |
| 2 <none> |
| </Code> |
| |
| The reason why you don't see anything in the "change-cause" is because we didn't use "-record" when we applied the change. But let's reverse our changes and apply them again. We can reverse our changes using the following command: |
| |
| <Code: bash| Rollback> |
| ubuntu@k8s-master:~$ kubectl rollout undo deployment hello-deploy --to-revision=1 |
| deployment.apps/hello-deploy rolled back |
| ubuntu@k8s-master:~$ |
| </Code> |
| |
| Of course we can monitor it with the same command as before: |
| |
| <Code: bash| Rollback> |
| ubuntu@k8s-master:~$ kubectl rollout status deploy hello-deploy |
| Waiting for deployment "hello-deploy" rollout to finish: 4 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 4 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 6 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 6 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 6 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 6 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 6 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 8 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 8 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 8 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 8 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 8 out of 10 new replicas have been updated... |
| Waiting for deployment "hello-deploy" rollout to finish: 1 old replicas are pending termination... |
| Waiting for deployment "hello-deploy" rollout to finish: 1 old replicas are pending termination... |
| Waiting for deployment "hello-deploy" rollout to finish: 1 old replicas are pending termination... |
| Waiting for deployment "hello-deploy" rollout to finish: 1 old replicas are pending termination... |
| deployment "hello-deploy" successfully rolled out |
| ubuntu@k8s-master:~$ kubectl describe deploy |
| Name: hello-deploy |
| Namespace: default |
| CreationTimestamp: Sun, 03 May 2020 11:28:33 +0000 |
| Labels: <none> |
| Annotations: deployment.kubernetes.io/revision: 3 |
| Selector: app=hello-date |
| Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable |
| StrategyType: RollingUpdate |
| MinReadySeconds: 10 |
| RollingUpdateStrategy: 1 max unavailable, 1 max surge |
| Pod Template: |
| Labels: app=hello-date |
| Containers: |
| hello-pod: |
| Image: andonovj/httpserverdemo:latest <- We are back to the old deployment. |
| Port: 1234/TCP |
| Host Port: 0/TCP |
| Environment: <none> |
| Mounts: <none> |
| Volumes: <none> |
| Conditions: |
| Type Status Reason |
| ---- ------ ------ |
| Available True MinimumReplicasAvailable |
| Progressing True NewReplicaSetAvailable |
| OldReplicaSets: <none> |
| NewReplicaSet: hello-deploy-6cd458494 (10/10 replicas created) |
| Events: |
| Type Reason Age From Message |
| ---- ------ ---- ---- ------- |
| Normal ScalingReplicaSet 45m deployment-controller Scaled up replica set hello-deploy-6cd458494 to 10 |
| Normal ScalingReplicaSet 44m deployment-controller Scaled up replica set hello-deploy-7f44bd8b96 to 1 |
| Normal ScalingReplicaSet 44m deployment-controller Scaled down replica set hello-deploy-6cd458494 to 9 |
| </Code> |
| |
| ====Rollupdate with Record==== |
| Let's again apply the RollUpdate WITH the record this time: |
| |
| <Code: bash|Rollupdate with Record> |
| ubuntu@k8s-master:~$ kubectl apply -f deploy.yml --record |
| deployment.apps/hello-deploy configured |
| ubuntu@k8s-master:~$ |
| ubuntu@k8s-master:~$ kubectl rollout history deploy hello-deploy |
| deployment.apps/hello-deploy |
| REVISION CHANGE-CAUSE |
| 3 <none> |
| 4 kubectl apply --filename=deploy.yml --record=true |
| </Code> |
| |
| Now, we can see that, the record is there and we can see the history of changes. |