kubernetes scale与rollout区别
1. scale
如果当前replicas与scale的 replicas一致,不会有任何操作
zhancj@iZbp10j40ovkbwx9an9ppuZ:~$ sudo kubectl scale deploy sport --replicas=3
deployment.apps/sport scaled
zhancj@iZbp10j40ovkbwx9an9ppuZ:~$ sudo kubectl get pods -l app=sport -w
NAME READY STATUS RESTARTS AGE
sport-55b68966c8-4wdd4 1/1 Running 26 27d
sport-55b68966c8-dct5g 1/1 Running 30 27d
sport-55b68966c8-k7tfl 1/1 Running 30 27d
^Czhancj@iZbp10j40ovkbwx9an9ppuZ:~$ sudo kubectl get pods -l app=sport -w
NAME READY STATUS RESTARTS AGE
sport-55b68966c8-4wdd4 1/1 Running 26 27d
sport-55b68966c8-dct5g 1/1 Running 30 27d
sport-55b68966c8-k7tfl 1/1 Running 30 27d
2. rollout restart
不论当前replicas,都会根据最新的deployment进行重启
qiteck@server:~$ sudo kubectl get pods -l app=sport
NAME READY STATUS RESTARTS AGE
sport-58df755f85-84sgk 1/1 Running 0 50d
sport-58df755f85-q7n7z 1/1 Running 0 50d
qiteck@server:~$
qiteck@server:~$ sudo kubectl rollout restart deployment sport
deployment.apps/sport restarted
qiteck@server:~$ sudo kubectl get pods -l app=sport -w
NAME READY STATUS RESTARTS AGE
sport-58df755f85-84sgk 1/1 Running 0 50d
sport-58df755f85-q7n7z 1/1 Running 0 50d
sport-5f748975cc-d496r 0/2 Init:0/1 0 3s
sport-5f748975cc-d496r 0/2 PodInitializing 0 3s
sport-5f748975cc-d496r 0/2 Running 0 7s
sport-5f748975cc-d496r 0/2 Error 0 8s
sport-5f748975cc-d496r 0/2 Running 1 (1s ago) 9s
sport-5f748975cc-d496r 1/2 Running 1 (2s ago) 10s
sport-5f748975cc-d496r 2/2 Running 1 (33s ago) 41s
sport-58df755f85-84sgk 1/1 Terminating 0 50d
sport-5f748975cc-58h7h 0/2 Pending 0 0s
sport-5f748975cc-58h7h 0/2 Pending 0 0s
sport-5f748975cc-58h7h 0/2 Init:0/1 0 0s
sport-58df755f85-84sgk 0/1 Terminating 0 50d
sport-58df755f85-84sgk 0/1 Terminating 0 50d
sport-58df755f85-84sgk 0/1 Terminating 0 50d
sport-5f748975cc-58h7h 0/2 PodInitializing 0 3s
sport-5f748975cc-58h7h 0/2 Running 0 5s
sport-5f748975cc-58h7h 0/2 Error 0 6s
sport-5f748975cc-58h7h 0/2 Running 1 (3s ago) 7s
sport-5f748975cc-58h7h 0/2 Error 1 (4s ago) 8s
sport-5f748975cc-58h7h 0/2 CrashLoopBackOff 1 (2s ago) 9s
sport-5f748975cc-58h7h 1/2 CrashLoopBackOff 1 (4s ago) 11s
sport-5f748975cc-58h7h 1/2 Running 2 (19s ago) 26s
sport-5f748975cc-58h7h 2/2 Running 2 (54s ago) 61s
sport-58df755f85-q7n7z 1/1 Terminating 0 50d
sport-58df755f85-q7n7z 0/1 Terminating 0 50d
sport-58df755f85-q7n7z 0/1 Terminating 0 50d
sport-58df755f85-q7n7z 0/1 Terminating 0 50d