(1) on both DebianNode and DebianNode2, retag "nigelpoulton/k8sbook:latest" to "nigelpoulton/k8sbook:edge" for ease of Deployment RollingUpdate, without downloading the actual 'nigelpoulton/k8sbook:edge' docker image.
$sudo docker images
$sudo docker tag nigelpoulton/k8sbook:latest nigelpoulton/k8sbook:edge
$sudo docker images
(2) add 'imagePullPolicy: IfNotPresent' to deploy.yml:
(12:20 dabs@CNU1343VF8 k8sbook) > cat deploy-latest.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-deploy
spec:
replicas: 10
selector:
matchLabels:
app: hello-world
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/k8sbook:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
(3) apply Deployment(deploy-latest.yml)
(12:28 dabs@CNU1343VF8 k8sbook) > kubectl apply -f deploy-latest.yml --record
deployment.apps/hello-deploy created
(12:30 dabs@CNU1343VF8 k8sbook) > kubectl rollout status deploy hello-deploy
Waiting for deployment "hello-deploy" rollout to finish: 0 of 10 updated replicas are available...
Waiting for deployment "hello-deploy" rollout to finish: 2 of 10 updated replicas are available...
deployment "hello-deploy" successfully rolled out
(12:30 dabs@CNU1343VF8 k8sbook) > kubectl get rs
NAME DESIRED CURRENT READY AGE
hello-deploy-5b6898688b 10 10 10 53s
(12:31 dabs@CNU1343VF8 k8sbook) > kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-deploy-5b6898688b-dpgnj 1/1 Running 0 59s 10.244.1.42 debiannode <none> <none>
hello-deploy-5b6898688b-h8z2s 1/1 Running 0 59s 10.244.2.37 debiannode2 <none> <none>
hello-deploy-5b6898688b-jcqjq 1/1 Running 0 59s 10.244.1.39 debiannode <none> <none>
hello-deploy-5b6898688b-kjbdw 1/1 Running 0 59s 10.244.1.40 debiannode <none> <none>
hello-deploy-5b6898688b-nb5zx 1/1 Running 0 59s 10.244.2.33 debiannode2 <none> <none>
hello-deploy-5b6898688b-q2bqg 1/1 Running 0 59s 10.244.2.34 debiannode2 <none> <none>
hello-deploy-5b6898688b-qzdjp 1/1 Running 0 59s 10.244.2.35 debiannode2 <none> <none>
hello-deploy-5b6898688b-s8mkp 1/1 Running 0 59s 10.244.1.41 debiannode <none> <none>
hello-deploy-5b6898688b-vrkn6 1/1 Running 0 59s 10.244.2.36 debiannode2 <none> <none>
hello-deploy-5b6898688b-vzvfm 1/1 Running 0 59s 10.244.1.38 debiannode <none> <none>
(12:31 dabs@CNU1343VF8 k8sbook) > kubectl rollout history deploy hello-deploy
deployment.apps/hello-deploy
REVISION CHANGE-CAUSE
1 kubectl apply --filename=deploy-latest.yml --record=true
Note: skip the 'Accessing the app' part for now
(4) apply Deployment RollingUpdate(deploy.yml)
Note: remember to add 'imagePullPolicy: IfNotPresent' to deploy.yml
(12:32 dabs@CNU1343VF8 k8sbook) > kubectl apply -f deploy.yml --record
deployment.apps/hello-deploy configured
(12:34 dabs@CNU1343VF8 k8sbook) > kubectl rollout status deploy hello-deploy
Waiting for deployment "hello-deploy" rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for deployment "hello-deploy" rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for deployment "hello-deploy" rollout to finish: 2 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: 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: 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: 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
(12:35 dabs@CNU1343VF8 k8sbook) > kubectl get rs
NAME DESIRED CURRENT READY AGE
hello-deploy-5b6898688b 0 0 0 5m34s
hello-deploy-79f969cff6 10 10 10 64s
(12:36 dabs@CNU1343VF8 k8sbook) > kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-deploy-5b6898688b-h8z2s 1/1 Terminating 0 5m37s 10.244.2.37 debiannode2 <none> <none>
hello-deploy-5b6898688b-q2bqg 1/1 Terminating 0 5m37s 10.244.2.34 debiannode2 <none> <none>
hello-deploy-5b6898688b-vzvfm 1/1 Terminating 0 5m37s 10.244.1.38 debiannode <none> <none>
hello-deploy-79f969cff6-22ctj 1/1 Running 0 20s 10.244.1.46 debiannode <none> <none>
hello-deploy-79f969cff6-4zn9s 1/1 Running 0 20s 10.244.1.47 debiannode <none> <none>
hello-deploy-79f969cff6-5fwpv 1/1 Running 0 43s 10.244.2.40 debiannode2 <none> <none>
hello-deploy-79f969cff6-bbq4m 1/1 Running 0 67s 10.244.2.38 debiannode2 <none> <none>
hello-deploy-79f969cff6-fd4rm 1/1 Running 0 55s 10.244.2.39 debiannode2 <none> <none>
hello-deploy-79f969cff6-gpw8v 1/1 Running 0 32s 10.244.2.42 debiannode2 <none> <none>
hello-deploy-79f969cff6-krrkx 1/1 Running 0 55s 10.244.1.44 debiannode <none> <none>
hello-deploy-79f969cff6-ltzcp 1/1 Running 0 32s 10.244.2.41 debiannode2 <none> <none>
hello-deploy-79f969cff6-tsp48 1/1 Running 0 43s 10.244.1.45 debiannode <none> <none>
hello-deploy-79f969cff6-zftmh 1/1 Running 0 67s 10.244.1.43 debiannode <none> <none>
(12:36 dabs@CNU1343VF8 k8sbook) > kubectl rollout history deploy hello-deploy
deployment.apps/hello-deploy
REVISION CHANGE-CAUSE
1 kubectl apply --filename=deploy-latest.yml --record=true
2 kubectl apply --filename=deploy.yml --record=true
(5) apply Deployment Rollback(--to-revision=1)
(12:36 dabs@CNU1343VF8 k8sbook) > kubectl rollout undo deploy hello-deploy --to-revision=1
deployment.apps/hello-deploy rolled back
(12:37 dabs@CNU1343VF8 k8sbook) > kubectl rollout status deploy hello-deploy
Waiting for deployment "hello-deploy" rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for deployment "hello-deploy" rollout to finish: 2 out of 10 new replicas have been updated...
Waiting for deployment "hello-deploy" rollout to finish: 2 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: 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: 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: 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: 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
(12:38 dabs@CNU1343VF8 k8sbook) > kubectl get rs
NAME DESIRED CURRENT READY AGE
hello-deploy-5b6898688b 10 10 10 8m22s
hello-deploy-79f969cff6 0 0 0 3m52s
(12:38 dabs@CNU1343VF8 k8sbook) > kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-deploy-5b6898688b-bknnr 1/1 Running 0 59s 10.244.1.49 debiannode <none> <none>
hello-deploy-5b6898688b-bv9cb 1/1 Running 0 59s 10.244.2.44 debiannode2 <none> <none>
hello-deploy-5b6898688b-ch9mh 1/1 Running 0 71s 10.244.2.43 debiannode2 <none> <none>
hello-deploy-5b6898688b-fpqpv 1/1 Running 0 23s 10.244.1.52 debiannode <none> <none>
hello-deploy-5b6898688b-gc6wm 1/1 Running 0 35s 10.244.2.46 debiannode2 <none> <none>
hello-deploy-5b6898688b-h9269 1/1 Running 0 35s 10.244.1.51 debiannode <none> <none>
hello-deploy-5b6898688b-jjgmn 1/1 Running 0 47s 10.244.1.50 debiannode <none> <none>
hello-deploy-5b6898688b-p7ntx 1/1 Running 0 47s 10.244.2.45 debiannode2 <none> <none>
hello-deploy-5b6898688b-w75j9 1/1 Running 0 23s 10.244.1.53 debiannode <none> <none>
hello-deploy-5b6898688b-zxn7k 1/1 Running 0 71s 10.244.1.48 debiannode <none> <none>
hello-deploy-79f969cff6-5fwpv 0/1 Terminating 0 3m34s 10.244.2.40 debiannode2 <none> <none>
hello-deploy-79f969cff6-bbq4m 1/1 Terminating 0 3m58s 10.244.2.38 debiannode2 <none> <none>
hello-deploy-79f969cff6-fd4rm 0/1 Terminating 0 3m46s 10.244.2.39 debiannode2 <none> <none>
hello-deploy-79f969cff6-krrkx 1/1 Terminating 0 3m46s 10.244.1.44 debiannode <none> <none>
hello-deploy-79f969cff6-zftmh 1/1 Terminating 0 3m58s 10.244.1.43 debiannode <none> <none>
(12:38 dabs@CNU1343VF8 k8sbook) > kubectl rollout history deploy hello-deploy
deployment.apps/hello-deploy
REVISION CHANGE-CAUSE
2 kubectl apply --filename=deploy.yml --record=true
3 kubectl apply --filename=deploy-latest.yml --record=true