deployment
直接修改deployment镜像
kubectl set image deployment/nginx-deployment nginx=nginx:1.91
回滚deployment变更
kubectl rollout undo deployment/nginx-deployment
查询deployment信息
kubectl describe deployment nginx-deployment
deployment变更历史查询
kubectl rollout history deployment/nginx-deployment
查看deployment变更历史中某个版本(版本号是变更历史查询到的版本号)的细节
kubectl rollout history deployment/nginx-deployment --revision=2
回滚deployment到某个版本号,前面两个命令可以查看历史版本信息
kubectl rollout undo deployment/nginx-deployment --to-revision=6
不要触发deployment的自动滚动更新功能:
kubectl rollout pause deployment/nginx-deployment
恢复deployment的自动滚动更新功能
kubectl rollout resume deploy/nginx-deployment
命令式-更新deployment
kubectl replace -f nginx.yaml
声明式API-创建或者更新deployment
kubectl apply -f nginx.yaml
副本
查询副本
kubectl get rs
POD
通过标签查询pods
kubectl get pods -w -l app=nginx
服务
Headless Service的DNS域名记录格式
<pod-name>.<svc-name>.<namespace>.svc.cluster.local
默认的命名空间为default
进入容器
进入容器查询容器主机名字
kubectl exec web-0 -- sh -c 'hostname'
技术咨询与支持,可以扫描微信公众号进行回复咨询
K8S命令大全1, kubernetes3