kubernetes

why kubectl run onfail1 --image=alpine --restart=OnFailure -- exit 0, pod status=CrashLoopBackOff, i think should be completed


enter image description here

kubectl run onfail1 --image=alpine --restart=OnFailure -- exit 0.

finally, this pod status=CrashLoopBackOff.

i think should be completed, because exit code = 0, so this pod not restart.

why? this status should be completed. could you tell me why?


Solution

  • you can see the error with the command:

    kubectl describe pods onfail1
    

    The error is caused beacuse the command 'exit' is not found in $PATH.

    You can edit your command as below and the pod will complete succesfully

    kubectl run onfail1 --image=alpine --restart=OnFailure -- echo "Hello world"