Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the pods returns Error or ExitCode:0 even they run successfully?

There's two kinds of status code of one-shot pods, running from API or the command:

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

The pods produce output files to a NFS server, and I've got files successfully.

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

the description of 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

the description of 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

Their NFS volumes:

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 returns none, since the container just produces output files.

Thanks in advance!

like image 857
Yang Avatar asked Dec 10 '25 00:12

Yang


1 Answers

ExitCode 0 means it terminated normally

Exit codes can be used if you pipe to another process, so the process knows what to do next (if previous process failed do this, else do something with the data passed...)

like image 86
MrE Avatar answered Dec 12 '25 13:12

MrE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!