1. 查询命名空间:kubectl get namespaces 或 ns
2. 查询服务名:kubectl get services 或 svc
3. 查询对应命名空间下的服务名:kubectl -n {namespace} get services 或 svc
4. 根据命名空间下某个服务的查询日志:kubectl -n {namespace} logs -f {serverName} --tail100
5. 获取节点名列表:kubectl get nodes 或 node
6. 编辑节点配置信息:kubectl edit nodes {node-name}
7. 查看节点配置信息:kubectl describe nodes {node-name}
8. 查看cm配置信息:kubectl get cm 或 configmap
9. 编辑cm配置信息:kubectl edit cm {configmap-name}
10. 查询pod(以ns为onap为例):kubectl -n onap get pods 或 pod 或 po
11. 加参数 -o wide 可显示运行节点和暴露端口:kubectl -n onap get pod -o wide
12. 查看service:kubectl get services 或 service 或 svc
13. 使用 --revision参数指定某个历史版本:kubectl rollout history deployment/nginx-deployment
14. 暂停deployment的更新:kubectl rollout pause deployment/nginx-deployment
15. 恢复deployment的更新:kubectl rollout resume deployment/nginx-deployment
16. 查看集群信息:kubectl cluster-info
17. 查看各组件信息:kubectl get componentstatuses 或 cs
18. 查看当前所有的pod:kubectl get pods 或 po
19. 查看pods所在的运行节点:kubectl get pods -o wide
20. 查看pods定义的详细信息:kubectl get pods -o yaml
21. 查看Replication Controller信息:kubectl get rc 或 replicationcontrollers
22. 查看daemonset信息:kubectl get daemonsets 或 daemonset
23. 查看deployments信息:kubectl get deployments 或 deploy
24. 按名称选择pod:kubectl get pods --selector name=redis
25.查看命名空间资源使用情况:kubectl top resource --namespace={namespace-name} --sort=cpu --sort=memory
【Kubernetes】之常用命令
最新推荐文章于 2024-09-12 17:37:20 发布