0

我在 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 上的有限资源有关。但我需要确认这一点。我在哪里可以找到与该 pod 被驱逐原因相关的日志?我在 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)"

但以上都没有给我一个关于原因和为什么会发生的提示。有什么建议吗?

4

2 回答 2

1

所以我不知道正确的方法是什么,但是当 k8s 无法给我足够的信息时,我会这样做。

最简单的事情就是看到docker logs那个吊舱。我看到某个 pod 一次又一次地失败。所以我会转到 minikube 机器并运行

docker ps -a | grep 'some_identifiable_name'

这是我获得容器 ID 的地方。一旦有了它,我就会得到那个 pod 的日志。

docker logs <id_found_above>

这应该很快完成,因为 k8s 可能会在您执行上述所有步骤之前对容器进行垃圾收集。

于 2017-04-04T05:19:58.680 回答
0

要以简单的方式获取每个 pod 的日志,请运行以下命令,

$ minikube dashboard

然后kubernetes仪表板将在您的浏览器中打开。然后转到Pods,在容器选项卡下,将有一个选项View logs,您可以从中实际查看容器内部发生的情况或失败的原因

于 2017-04-11T08:50:27.130 回答