K8S常用命令

kubectl get 命令查看资源的运行状态

kubectl get pod|rs|deploy
kubectl命令行中的资源名称及简写

资源名称 简写
pods po
namespaces Ns
services svc
nodes no
events ev
ingress ing
deployments deploy
查看node状态及信息

kubectl get nodes
kubectl describe node [node_name]

查看pods状态

kubectl get po|pods --all-namespaces
kubectl get pods --all-namespaces -o wide

查看Pod事件

kubectl describe pod pod_name

查看service状态

kubectl get svc --all-namespaces -o wide

查看Deployment信息

kubectl get deploy --all-namespaces -o wide

查看容器日志

kubectl logs -f pod_name

进入pod容器

kubectl --namespace=test-system exec -it pod_name -- sh
kubectl --namespace=test-system exec -it tomcat-deploy-66b57cf6df-nrr9j -- sh

查看Kubernetes服务日志

systemctl status kube-controller-manager -l

journalctl -u kube-controller-manager

kubectl describe 加上资源类型和资源名称,就可以获得指定资源实例的详细信息
#kubectl describe pod kubernetes-dashboard-76f6bf8c57-kw855 -n kube-system

Pod的升级与更新

方法一:
kubectl set image deploy/user-center user-center=www.node175.com/test/base-tomcat:v4 -n test-system

方法二:
kubectl edit deploy/user-center -n test-system
#查看升级状态
kubectl rollout status deployment/user-center -n test-system

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章