04.pod问题排查思路

查看是否有pod状态为ERROR
kubectl get pod

查看异常pod的详细信息
kucectl describe pod pod名字

查看异常pod里的容器的log
kubectl log pod名字 -c 容器名

Kubernetes 执行的过程中,对 API 对象的所有重要操作,都会被记录在这个对象的 Events 里,并且显示在 kubectl describe 指令返回的结果中。
比如,对于这个 Pod,我们可以看到它被创建之后,被调度器调度(Successfully assigned)到了 node-1,拉取了指定的镜像(pulling image),然后启动了 Pod 里定义的容器(Started container)。所以,这个部分正是我们将来进行 Debug 的重要依据。如果有异常发生,你一定要第一时间查看这些 Events



kubectl describe pod nginx-deployment-67254d7ar6-9bdvr

Name:               nginx-deployment-67254d7ar6-9bdvr
Namespace:          default
Priority:           0
PriorityClassName:  
Node:               node-1/10.168.0.3
Start Time:         Thu, 03 Aug 2020 20:36:42 +0000
Labels:             app=nginx
                    pod-template-hash=2321707621
Annotations:        
Status:             Running
IP:                 10.32.0.23
Controlled By:      ReplicaSet/nginx-deployment-67254d7ar6
...
Events:

  Type     Reason                  Age                From               Message

  ----     ------                  ----               ----               -------
  
  Normal   Scheduled               1m                 default-scheduler  Successfully assigned default/nginx-deployment-67254d7ar6-9bdvr to node-1
  Normal   Pulling                 23s                kubelet, node-1    pulling image "nginx:1.7.9"
  Normal   Pulled                  15s                kubelet, node-1    Successfully pulled image "nginx:1.7.9"
  Normal   Created                 16s                kubelet, node-1    Created container
  Normal   Started                 16s                kubelet, node-1    Started container

你可能感兴趣的:(04.pod问题排查思路)