[K8s problem location] pods in k8s keep restarting, locate the cause and solution of the problem

Phenomenon: A running pod restarts too many times in a short period of time

 How to locate the problem: View pod logs

kubectl get event                           #查看当前环境一个小时内的日志
kubectl describe pod pod_name               #查看当前pod的日志    

kubectl  logs -f  pod_name --previous       #查看重启之前的那一次pod的日志,从那一刻开始计算


###############
一般用以上的三个命令就行

This time using the following command solved the problem

kubectl describe pod pod_name     

Cause of the problem: OOM, pod was killed and restarted ( not enough memory )

 View the deployment.yaml file of the service

It was found that our deployment.yaml has restricted the memory usage of the service.

Solution: Increase the memory value of limit, then delete -f yaml, and then apply -f yaml


It’s not easy for newcomers to create. If you think it’s good, please give it a thumbs up! ! !

Please indicate the source when reprinting!

                                                     

Guess you like

Origin blog.csdn.net/weixin_43784564/article/details/131142017