我一直在某些 pod 停留在初始化阶段遇到问题。
运行pod describe
命令时没有看到任何错误。这是事件列表:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 5m default-scheduler Successfully assigned infrastructure/jenkins-74cc957b47-mxvqd to ip-XX-XX-XXX-XXX.eu-west-1.compute.internal
Warning BackOff 3m (x3 over 4m) kubelet, ip-XX-XX-XXX-XXX.eu-west-1.compute.internal Back-off restarting failed container
Normal Pulling 3m (x4 over 5m) kubelet, ip-XX-XX-XXX-XXX.eu-west-1.compute.internal pulling image "jenkins/jenkins:lts"
Normal Pulled 3m (x4 over 5m) kubelet, ip-XX-XX-XXX-XXX.eu-west-1.compute.internal Successfully pulled image "jenkins/jenkins:lts"
Normal Created 3m (x4 over 5m) kubelet, ip-XX-XX-XXX-XXX.eu-west-1.compute.internal Created container
Normal Started 3m (x4 over 5m) kubelet, ip-XX-XX-XXX-XXX.eu-west-1.compute.internal Started container
我也可以看到: State: Running
Started: Wed, 23 Sep 2020 09:49:56 +0200
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Wed, 23 Sep 2020 09:49:06 +0200
Finished: Wed, 23 Sep 2020 09:49:27 +0200
Ready: False
Restart Count: 3
如果我列出 pod ,它看起来像这样:Error from server (BadRequest): container "jenkins" in pod "jenkins-74cc957b47-mxvqd" is waiting to start: PodInitializing
但是我看不到具体错误。有人可以帮忙吗? 最佳答案
官方文档中有一些有关Debug Running Pods的建议:
kubectl logs ${POD_NAME} ${CONTAINER_NAME}
或kubectl logs --previous ${POD_NAME} ${CONTAINER_NAME}
kubectl exec
在特定容器内运行命令:kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} -- ${CMD} ${ARG1} ${ARG2} ... ${ARGN}
kubectl exec
不足,因为容器崩溃或容器镜像不包含调试实用程序时,临时容器可用于交互式故障排除。您可以找到一个示例here。您可以在链接的文档中找到更多详细信息。
关于kubernetes - Kubernetes Pod处于初始化阶段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64023429/