【问题标题】:Why the pods returns Error or ExitCode:0 even they run successfully?为什么 pod 即使成功运行也会返回 Error 或 ExitCode:0?
【发布时间】:2016-01-22 01:45:11
【问题描述】:

one-shot Pod 的状态码有两种,通过 API 或命令运行:

kubectl run --restart=Never --image test:v0.1 ....

pod 将输出文件生成到 NFS 服务器,并且我已成功获取文件。

kubectl get pods -ao wide:

NAME       READY     STATUS       RESTARTS   AGE       
test-90    0/1       ExitCode:0   0          23m       192.168.1.43
test-91    0/1       ExitCode:0   0          23m       192.168.1.43
test-92    0/1       ExitCode:0   0          23m       192.168.1.43
test-93    0/1       ExitCode:0   0          23m       192.168.1.43
test-94    0/1       Error        0          23m       192.168.1.46
test-95    0/1       Error        0          23m       192.168.1.46
test-96    0/1       Error        0          23m       192.168.1.46
test-97    0/1       Error        0          23m       192.168.1.46
test-98    0/1       Error        0          23m       192.168.1.46
test-99    0/1       ExitCode:0   0          23m       192.168.1.43

ExitCode:0 pod 的描述:

Name:                           test-99
Namespace:                      default
Image(s):                       test:v0.1
Node:                           192.168.1.43/192.168.1.43
Status:                         Succeeded
Replication Controllers:        <none>
Containers:
  test:
    State:              Terminated
      Exit Code:        0
    Ready:              False
    Restart Count:      0

Error pod 的描述:

Name:                           test-98
Namespace:                      default
Image(s):                       test:v0.1
Node:                           192.168.1.46/192.168.1.46
Status:                         Succeeded
Replication Controllers:        <none>
Containers:
  test:
    State:              Terminated
      Reason:           Error
      Exit Code:        0
    Ready:              False
    Restart Count:      0

他们的 NFS 卷:

Volumes:
  input:
    Type:       NFS (an NFS mount that lasts the lifetime of a pod)
    Server:     192.168.1.46
    Path:       /srv/nfs4/input
    ReadOnly:   false
  output:
    Type:       NFS (an NFS mount that lasts the lifetime of a pod)
    Server:     192.168.1.46
    Path:       /srv/nfs4/output
    ReadOnly:   false
  default-token-nmviv:
    Type:       Secret (a secret that should populate this volume)
    SecretName: default-token-nmviv

kubectl logs 不返回任何内容,因为容器只生成输出文件。

提前致谢!

【问题讨论】:

  • 你使用什么版本的 kubernetes? kubectl version
  • @Yu-JuHong Kubernetes 1.1.2 在 Ubuntu 14.04 上,任何传递到 pod 的命令都会返回错误状态。
  • 我在使用 Kubernetes v1.1.4 时遇到了同样的问题,你找到原因了吗?我实际上只是按照简单的 hello-world 示例,将 restartPolicy 设置为 Never。
  • @zyxue 还没有。一个合理的解释是quickly existing。但是如果ExitCode 0是正常的,那Error呢?我尝试在本地机器上运行 docker,在 docker 中调试,所有这些都工作正常。 XD

标签: docker kubernetes nfs


【解决方案1】:

ExitCode 0 表示正常终止

如果您通过管道传输到另一个进程,则可以使用退出代码,因此该进程知道下一步该做什么(如果前一个进程失败,请执行此操作,否则对传递的数据执行某些操作...)

【讨论】:

  • 谢谢!我已经在容器中测试了脚本,退出代码正是0,但是为什么有些豆荚以Error 终止?
  • 好吧,我认为如果复制控制器成功启动每个请求的 pod,则复制控制器表示成功,在旅游案例中,这是一个一次性过程,因此只要图像可以运行,它就会始终成功.现在为什么 pod 可能会出现错误退出取决于您实际运行的内容。它可能无法挂载 nfs 存储并失败。您需要在图像中输出一些内容以检查并获取有关正在发生的事情的有用日志
  • 谢谢!我刚才检查了 nfs 服务器中的输出文件,并且文件按预期存储。这个问题真的很牵强。
猜你喜欢
  • 2012-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多