如何调试Kubernetes pod终止的原因

时间:2017-06-01 13:56:13

标签: kubernetes google-kubernetes-engine traefik

我的设置适用于我当地的Minikube。但是在GCE中,Traefik控制器在成功启动后大约半分钟终止(Started container with docker id xxxtraefik-ingress-controller-d8jb6 1/1 Running)。 当pod运行时,我没有从kubectl describe pod --selector=k8s-app=traefik-ingress-lb --namespace=kube-system获得任何新事件。但由于我不能跟describe -f命令一样,我可以按照logs命令,我不知道是否有任何新事件在描述错误的pod终止之前弹出。< / p> BTW:GCE仍然使用Kubernetes 1.5.7。

在Minikube和GCE中,Ingress似乎找到了服务,因为我在容器中看到以下日志输出:

time="2017-06-01T11:57:56Z" level=debug msg="Configuration received from provider kubernetes: {"backends":{"www.sandroboehme.de/":{"servers":{"web-deployment-439093506-08dk8":{"url":"http://10.0.0.4:8080","weight":1}},"loadBalancer":{"method":"wrr"}}},"frontends":{"www.sandroboehme.de/":{"entryPoints":["http"],"backend":"www.sandroboehme.de/","routes":{"/":{"rule":"PathPrefix:/"},"www.sandroboehme.de":{"rule":"Host:www.sandroboehme.de"}},"passHostHeader":true,"priority":1,"basicAuth":[]}}}" 
time="2017-06-01T11:57:56Z" level=debug msg="Last kubernetes config received more than 2s, OK" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating frontend www.sandroboehme.de/" 
time="2017-06-01T11:57:56Z" level=debug msg="Wiring frontend www.sandroboehme.de/ to entryPoint http" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating route / PathPrefix:/" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating route www.sandroboehme.de Host:www.sandroboehme.de" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating backend www.sandroboehme.de/" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating load-balancer wrr" 
time="2017-06-01T11:57:56Z" level=debug msg="Creating server web-deployment-439093506-08dk8 at http://10.0.0.4:8080 with weight 1" 
time="2017-06-01T11:57:56Z" level=info msg="Server configuration reloaded on :80"

但在GCE案例中,最后的日志消息如下:

time="2017-06-01T10:14:50Z" level=info msg="I have to go... terminated" 
time="2017-06-01T10:14:50Z" level=info msg="Stopping server" 
time="2017-06-01T10:14:50Z" level=debug msg="Waiting 10s seconds before killing connections on entrypoint http..." 
time="2017-06-01T10:14:50Z" level=debug msg="Entrypoint http closed" 
time="2017-06-01T10:14:50Z" level=info msg="Server stopped" 
time="2017-06-01T10:14:50Z" level=info msg="Shutting down" 
time="2017-06-01T10:14:50Z" level=error msg="Error creating server: http: Server closed"

如何调试以找出导致pod终止的原因?

可以在GitHub帐户https://github.com/sandroboehme/sling-gce-k8s-launchpad/tree/traefik/src/main/k8s找到完整的yaml文件,single-mongo文件夹在这种情况下不相关。请确保仅在GCE案例中使用googlecloud_hdd.yaml,并仅在Minikube案例中删除storage-class: "slow"。 非常感谢您的任何提示!

1 个答案:

答案 0 :(得分:-1)

您可以使用kubectl describe pod #####查看kubernetes事件。通常你可以在那里找到原因。