我在Virtual Box上的本地计算机上创建了一个Minikube实例。我有几个复制控制器,为它们都指定了资源限制。首先,我为每个复制控制器A和B创建了一个实例。然后我将rc B的复制计数增加到6.一旦扩展,我可以看到由rc A创建的Pod被Kubernetes杀死。只有我在kubeclt日志中可以看到的日志是
/opt/app-server/bin/app-server.sh: line 159: 28 Killed $JAVA_HOME/bin/java -server $JVM_OPTS $XDEBUG $SERVER_OPTS -Djava.endorsed.dirs=$SERVER_ENDORSED -classpath $SERVER_CLASSPATH org.adroitlogic.appserver.AppServer
我不知道驱逐这个吊舱的原因是什么。我猜这与pod的资源分配和VM上的有限资源有关。但我需要确认一下。我在哪里可以找到与驱逐该吊舱的原因相关的日志?我在journalctl -u localkube
中搜索Jan 09 11:00:55 minikube localkube[3421]: I0109 11:00:55.136114 3421 docker_manager.go:2524] checking backoff for container "ipsweb" in pod "ipsweb-m3234"
Jan 09 11:00:55 minikube localkube[3421]: I0109 11:00:55.136525 3421 docker_manager.go:2538] Back-off 5m0s restarting failed container=ipsweb pod=ipsweb-m3234_default(e6961157-d650-11e6-8bee-080027bc9720)
Jan 09 11:00:55 minikube localkube[3421]: E0109 11:00:55.136571 3421 pod_workers.go:184] Error syncing pod e6961157-d650-11e6-8bee-080027bc9720, skipping: failed to "StartContainer" for "ipsweb" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=ipsweb pod=ipsweb-m3234_default(e6961157-d650-11e6-8bee-080027bc9720)"
kubectl describe pod提供以下事件
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
1h 1h 1 {kubelet minikube} spec.containers{ipsweb} Normal Started Started container with docker id 2ca5ccaa11a1
1h 1h 1 {kubelet minikube} spec.containers{ipsweb} Normal Created Created container with docker id 2ca5ccaa11a1; Security:[seccomp=unconfined]
1h 1h 1 {kubelet minikube} spec.containers{ipsweb} Normal Started Started container with docker id 86d4bdfa014e
1h 1h 1 {kubelet minikube} spec.containers{ipsweb} Normal Created Created container with docker id 86d4bdfa014e; Security:[seccomp=unconfined]
50m 50m 1 {kubelet minikube} spec.containers{ipsweb} Normal Started Started container with docker id a570e4f59e96
50m 50m 1 {kubelet minikube} spec.containers{ipsweb} Normal Created Created container with docker id a570e4f59e96; Security:[seccomp=unconfined]
1h 49m 2 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ipsweb" with CrashLoopBackOff: "Back-off 10s restarting failed container=ipsweb pod=ipsweb-m3234_default(e6961157-d650-11e6-8bee-080027bc9720)"
49m 49m 1 {kubelet minikube} spec.containers{ipsweb} Normal Started Started container with docker id b91cc20a8bb3
49m 49m 1 {kubelet minikube} spec.containers{ipsweb} Normal Created Created container with docker id b91cc20a8bb3; Security:[seccomp=unconfined]
1h 48m 4 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ipsweb" with CrashLoopBackOff: "Back-off 20s restarting failed container=ipsweb pod=ipsweb-m3234_default(e6961157-d650-11e6-8bee-080027bc9720)"
48m 48m 1 {kubelet minikube} spec.containers{ipsweb} Normal Started Started container with docker id cf24faa31718
48m 48m 1 {kubelet minikube} spec.containers{ipsweb} Normal Created Created container with docker id cf24faa31718; Security:[seccomp=unconfined]
1h 46m 7 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ipsweb" with CrashLoopBackOff: "Back-off 40s restarting failed container=ipsweb pod=ipsweb-m3234_default(e6961157-d650-11e6-8bee-080027bc9720)"
但不是上述内容给了我一个关于原因以及为什么会发生这种情况的提示。有什么建议吗?
答案 0 :(得分:1)
所以我不知道这样做的正确方法是什么,但是当k8s无法给我足够的信息时,我就会这样做。
最简单的方法是查看该广告连播的docker logs
。我看到某个pod一次又一次失败。所以我会转到minikube机器并运行
docker ps -a | grep 'some_identifiable_name'
这是我获取容器ID的地方。有了这个,我就得到了那个pod的日志。
docker logs <id_found_above>
这应该很快完成,因为在你甚至可以执行上述所有步骤之前,k8可能会垃圾收集容器。
答案 1 :(得分:0)
要以简单的方式获取每个pod的日志,请运行以下命令,
$ minikube dashboard
然后kubernetes
信息中心将在您的浏览器中打开。然后转到Pods
,在容器标签下,会有选项View logs
,您可以从中实际查看容器内部的内容或其失败的原因