k8s中deployment管理使用记录(三)
deploy 升级及回滚Pods
一:从nginx:v1 升级到nginx:v2
1.查看当前部署
kubectl get deployment
kubectl get deployments -o wide
2.查看部署中pods使用的镜像
kubectl describe deployment
3.修改升级
kubectl edit deployment/nginx-v1-deploy
只修改镜像地址 由V1 改成V2
或
kubectl set image deployment/nginx-v1-deploy nginx-v1-deploy=k8s4:5000/nginx:v1.12.2
检查进度
kubectl rollout status deployment/nginx-v1-deploy
[root@k8s1 deploy]# kubectl edit deployment/nginx-v1-deploy
deployment.extensions/nginx-v1-deploy edited
4.查看部署进度及详情
kubectl describe deployments
5.验证容器是否使用了新镜像
方法1:
kubectl get deployments -o wide
方法2:
kubectl describe deployments nginx-v1-pods-deploy
方法3:
查看Pods
kubectl describe pods nginx-v1-pods-deploy-5f59589765-977ll
方法4:
验证pods容器内容
curl http://k8s2:31941
curl http://k8s3:31941
附加的一些操作,暂停和继续,回滚升级
$ kubectl rollout pause deployment/nginx-deployment2
$ kubectl rollout resume deployment/nginx-deployment2
$ kubectl rollout undo deployment/nginx-deployment2