-
Pod的擴(kuò)容和縮容
kubectl scale [資源對象rc,Deployment,...] [資源對象名稱metadata.name] --replicas=NUM
eg: kubectl scale rc myweb --replicas=3
升級與回滾
rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)
- 滾動升級(rolling-update):rolling-update命令一鍵完成升級,該命令會創(chuàng)建一個新的資源對象如RC,Deployment..然后控制舊的中的Pod數(shù)量,同時新的RC中的Pod數(shù)量主鍵增加到目標(biāo)值,最終實(shí)現(xiàn)Pod升級。(新舊RC需在同一個Namespace中)
#更新frontend-v1的pod到frontend-v2
kubectl rolling-update frontend-v1 frontend-v2 --image=image:v2 --record
#更新frontend的pods,不更改replication controller的名稱
kubectl rolling-update frontend --image=image:v2 --record
#不僅僅更新鏡像:
如果你不僅僅是需要更新鏡像,(例如,更新命令參數(shù),環(huán)境變量等),你可以創(chuàng)建一個新的replication controller配置文件,
包含一個新的名稱和不同的標(biāo)簽值 kubectl rolling-update my-nginx -f ./nginx-rc.yaml --record
-
非滾動升級方案:
舊版本:kubectl apply -f httpd.v1.yml --record
升級:kubectl apply -f httpd.v2.yml --record
回滾:查看舊版本號 kubectl rollout history deployment httpd
? 回滾到指定版本:kubectl rollout undo deployment httpd --to-revision=1
注:此方法可以在新的yml中指定滾動升級的參數(shù),實(shí)現(xiàn)滾動升級http://www.itdecent.cn/p/7411d15215b5