查看集群状态
1 2 3 4 5 |
kubectl cluster-info 查看集群信息 kubectl version 显示kube命令行及kube 服务端的版本 kubectl api-versions 显示支持的API版本集合 kubectl config view 显示当前kubectl配置 kubectl get no 查看集群节点 |
创建新资源
1 2 3 |
kubectl create -f <res.yaml> 按照yaml文件创建资源 kubectl run <name> --image=<image> 使用某镜像创建Deployment |
检查与调试
1 2 3 4 5 |
kubectl get <type> <name> 查看某种类型资源 kubectl describe <type> <name> 检查某特定资源实例 kubectl logs 检查某POD的日志(标准输出) kubectl exec -it <container name or id> /bin/bash 在容器内执行命令 |
部署管理
1 2 3 4 |
kubectl scale 实现水平扩展或收宿 kubectl rollout status 部署状态更状态检查 kubectl rollout history 部署的历史 kubectl rollout undo 回滚部署到最近或者某个版本 |
删除资源
1 2 3 4 5 6 7 8 9 10 11 |
kubectl delete <type> <name> kubectl get svc kubectl expose deploy nginx --type=NodePort --name=nginx-ext --port=80 kubectl get svc kubectl delete svc nginx-ext kubectl get ep ep endpoints |
横向扩容
1 2 3 4 5 6 7 |
kubectl scale deploy nginx --replicas=3 kubectl get deploy nginx kubectl get rs kubectl get po |
升级
1 2 3 |
kubectl set image deploy nginx nginx=nginx:1.9.1 kubectl rollout history deploy nginx |
可以看到滚动升级的过程
1 |
kubectl describe deploy nginx |
升级一个错误的版本,查看
1 2 3 |
kubectl set image deploy nginx nginx=nginx:1.9.1 kubectl rollout history deploy nginx kubectl rollout history deploy nginx --version=3 |
1 2 3 |
kubectl get rs kubectl get po kubectl describe po <pod id> |
回滚部署到最近或者某个版本
1 2 3 4 |
kubectl rollout undo deploy nginx kubectl get rs kubectl get po kubectl get ep |
1 2 3 4 5 |
kubectl delete po <pod id> kubectl get ep kubectl delete svc <service id> |
- 本文固定链接: https://www.yoyoask.com/?p=1932
- 转载请注明: shooter 于 SHOOTER 发表