1. 查看镜像定义的内容
docker image inspeck 镜像名:版本
2. 查看可回滚历史
# myapp-deploy 指定哪个 deployment
kubectl rollout history deployment myapp-deploy
3. 回滚到上一个版本
# rollout undo 回滚到上一版本的 deployment
kubectl rollout undo deployment myapp-deploy
4. 指定某个版本回滚
# --to-revision=1 指定某个版本号
kubectl rollout undo deployment myapp-deploy --to-revision=1
5. 查看deploy信息
kubectl get deploy
6. 查看 service 信息,可以看更新历史
kubectl get rs -o wide
7. 查看 指定 deploy 的详细信息
kubectl describe deploy myapp-deploy
8. 查看pods 更新状态,并实时监控状态变换
# -l 过滤指定的标签 app=myapp
# -w 实时监控状态
kubectl get pods -l app=myapp -w
9. 通过patch 更改镜像
# patch 打补丁形式更新
# -p 指定更新内容
kubectl patch deployment myapp-deploy -p '{"spec":{"template":{"spec":{"containers":{"name":{"image":"xxxxxxvvvv2"}}}}}}'
10. 通过 set 更改当前正在运行deployment的镜像
# kubectl set image deployment 固定语句
# myapp-deploy 指定 deployment
# myapp=ikubernetes/myapp:v3 指定 pod 为 myapp的镜像改为 ikubernetes/myapp:v3
kubectl set image deployment myapp-deploy myapp=ikubernetes/myapp:v3
11. 暂停更新过程
# rollout pause 暂停更新 deployment
kubectl rollout pause deployment myapp-deploy
**12. 继续更新 **
# rollout resume 继续更新 deployment
kubectl rollout resume deployment myapp-deploy
13. 监控更新过程
kubectl rollout status deployment myapp-deploy
14. 查看pod中有哪些标签
# --show-labels 查看pods 的标签信息
kubectl get pods --show-labels
15. 给指定的 pod 添加标签
kubectl label pods pod-demo app=zyuser
16. 查看运行中pod 的配置清单
[zyjenkins@server1 ~]$ kubectl get pods -n zy-dev ty-youlia d859-ckr4t -o yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
... ...
node操作
1. 给node节点添加 label标签
[zyjenkins@server1 target]$ kubectl label nodes host1 host2 host3 host4 server_type=worker
node/host1 labeled
node/host2 labeled
node/host3 labeled
node/host4 labeled
2. 查询出node 有server_type 标签的
[zyjenkins@server1 ~]$ kubectl get node -l server_type
NAME STATUS ROLES AGE VERSION
host1 Ready <none> 78d v1.12.6-aliyun.1
host2 Ready <none> 60d v1.12.6-aliyun.1
host3 Ready <none> 76d v1.12.6-aliyun.1
host4 Ready <none> 98d v1.12.6-aliyun.1