$ kubectl apply -f nginx-dp.yaml --record deployment.apps/nginx-dp created # 注:执行完立即执行rollout才能看到 $ kubectl rollout status deployment/nginx-dp Waiting for deployment "nginx-dp" rollout to finish: 0 of 3 updated replicas are available... Waiting for deployment "nginx-dp" rollout to finish: 1 of 3 updated replicas are available... Waiting for deployment "nginx-dp" rollout to finish: 2 of 3 updated replicas are available... deployment "nginx-dp" successfully rolled out $ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-d46f5678b 3 3 3 3m41s $ kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE nginx-dp 3/3 3 3 3m45s
$ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-7fb9ff5685 1 1 0 41s nginx-dp-d46f5678b 3 3 3 8m2s $ kubectl rollout status deployment/nginx-dp Waiting for deployment "nginx-dp" rollout to finish: 1 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 1 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 1 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 2 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 2 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 2 out of 3 new replicas have been updated... Waiting for deployment "nginx-dp" rollout to finish: 1 old replicas are pending termination... Waiting for deployment "nginx-dp" rollout to finish: 1 old replicas are pending termination... deployment "nginx-dp" successfully rolled out $ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-7fb9ff5685 3 3 3 10m nginx-dp-d46f5678b 0 0 0 17m $ kubectl describe deploy nginx-dp ... StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge ... OldReplicaSets: <none> NewReplicaSet: nginx-dp-7fb9ff5685 (3/3 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 18m deployment-controller Scaled up replica set nginx-dp-d46f5678b to 3 Normal ScalingReplicaSet 11m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 1 Normal ScalingReplicaSet 7m22s deployment-controller Scaled down replica set nginx-dp-d46f5678b to 2 Normal ScalingReplicaSet 7m22s deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 2 Normal ScalingReplicaSet 3m34s deployment-controller Scaled down replica set nginx-dp-d46f5678b to 1 Normal ScalingReplicaSet 3m34s deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 3 Normal ScalingReplicaSet 3m17s deployment-controller Scaled down replica set nginx-dp-d46f5678b to 0
$ kubectl set image deployment/nginx-dp nginx=nginx:1.91 deployment.apps/nginx-dp image updated $ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-6d6678fb55 1 1 0 6s nginx-dp-7fb9ff5685 3 3 3 24m nginx-dp-d46f5678b 0 0 0 31m $ kubectl get pods NAME READY STATUS RESTARTS AGE nginx-dp-6d6678fb55-4xxpv 0/1 ErrImagePull 0 72s nginx-dp-7fb9ff5685-25xlv 1/1 Running 0 25m nginx-dp-7fb9ff5685-jxvt8 1/1 Running 0 17m nginx-dp-7fb9ff5685-ld64t 1/1 Running 0 21m $ kubectl describe deployment nginx-dp ... OldReplicaSets: nginx-dp-7fb9ff5685 (3/3 replicas created) NewReplicaSet: nginx-dp-6d6678fb55 (1/1 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 33m deployment-controller Scaled up replica set nginx-dp-d46f5678b to 3 Normal ScalingReplicaSet 25m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 1 Normal ScalingReplicaSet 21m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 2 Normal ScalingReplicaSet 21m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 2 Normal ScalingReplicaSet 18m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 1 Normal ScalingReplicaSet 18m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 3 Normal ScalingReplicaSet 17m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 0 Normal ScalingReplicaSet 98s deployment-controller Scaled up replica set nginx-dp-6d6678fb55 to 1
$ kubectl rollout undo deployment/nginx-dp deployment.apps/nginx-dp rolled back $ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-6d6678fb55 0 0 0 6m49s nginx-dp-7fb9ff5685 3 3 3 30m nginx-dp-d46f5678b 0 0 0 38m $ kubectl describe deployment/nginx-dp ... OldReplicaSets: <none> NewReplicaSet: nginx-dp-7fb9ff5685 (3/3 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 38m deployment-controller Scaled up replica set nginx-dp-d46f5678b to 3 Normal ScalingReplicaSet 31m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 1 Normal ScalingReplicaSet 27m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 2 Normal ScalingReplicaSet 27m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 2 Normal ScalingReplicaSet 23m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 1 Normal ScalingReplicaSet 23m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 3 Normal ScalingReplicaSet 23m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 0 Normal ScalingReplicaSet 7m2s deployment-controller Scaled up replica set nginx-dp-6d6678fb55 to 1 Normal ScalingReplicaSet 19s deployment-controller Scaled down replica set nginx-dp-6d6678fb55 to 0 $ kubectl get pods NAME READY STATUS RESTARTS AGE nginx-dp-7fb9ff5685-25xlv 1/1 Running 0 40m nginx-dp-7fb9ff5685-jxvt8 1/1 Running 0 33m nginx-dp-7fb9ff5685-ld64t 1/1 Running 0 36m
$ kubectl set image deployment/nginx-dp nginx=nginx:1.18 deployment.apps/nginx-dp image updated $ kubectl get rs NAME DESIRED CURRENT READY AGE nginx-dp-6d6678fb55 0 0 0 37m nginx-dp-7fb9ff5685 0 0 0 61m nginx-dp-d46f5678b 3 3 3 68m $ kubectl describe deployment/nginx-dp ... OldReplicaSets: nginx-dp-d46f5678b (3/3 replicas created) NewReplicaSet: <none> Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 57m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 2 Normal ScalingReplicaSet 57m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 2 Normal ScalingReplicaSet 54m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 1 Normal ScalingReplicaSet 54m deployment-controller Scaled up replica set nginx-dp-7fb9ff5685 to 3 Normal ScalingReplicaSet 53m deployment-controller Scaled down replica set nginx-dp-d46f5678b to 0 Normal ScalingReplicaSet 37m deployment-controller Scaled up replica set nginx-dp-6d6678fb55 to 1 Normal ScalingReplicaSet 30m deployment-controller Scaled down replica set nginx-dp-6d6678fb55 to 0 Normal ScalingReplicaSet 8m32s deployment-controller Scaled up replica set nginx-dp-d46f5678b to 1 Normal ScalingReplicaSet 8m26s deployment-controller Scaled up replica set nginx-dp-d46f5678b to 2 Normal ScalingReplicaSet 8m26s deployment-controller Scaled down replica set nginx-dp-7fb9ff5685 to 2 Normal ScalingReplicaSet 8m22s (x2 over 69m) deployment-controller Scaled up replica set nginx-dp-d46f5678b to 3 Normal ScalingReplicaSet 8m22s deployment-controller Scaled down replica set nginx-dp-7fb9ff5685 to 1 Normal ScalingReplicaSet 8m17s deployment-controller Scaled down replica set nginx-dp-7fb9ff5685 to 0