Edith Puclla:
I created this pod:
k run hello --image=busybox --restart=Never -- echo "Hello World"
Then I am checking it :
controlplane $ k get pod
NAME READY STATUS RESTARTS AGE
hello 0/1 Completed 0 16m
The READY is 0/1, does it means that my pod lived just until execute the command “hello world”? It could be milliseconds, and the it dies?
Good morning, good afternoon, good night everyone
You, have a wonderful day today!
Mohamed Ihsan:
Also try with restart=Always parameter as well.
Edith Puclla:
let me try @Mohamed Ihsan
Edith Puclla:
This is restarting and I have this messages:
Warning BackOff 6s (x7 over 68s) kubelet Back-off restarting failed container
hello3 0/1 CrashLoopBackOff 3 85s
Why this is CrashLoopBackOff ? this simple container does not have to fail, why does putting restart = Always make it fail? @Mohamed Ihsan
Mohamed Ihsan:
This is the normal behavior.
k8s always wanna make the pod up and running. But if the pod doesn’t have a continuous program it will stop. hence you will end up in the start-stop loop. Which is noted as CrashLoopBackOff
Mohamed Ihsan:
In the first command you have change this with restart=Never
Edith Puclla:
I got it Thanks a lot
Sangeetha Radhakrishnan:
To debug CrashLoopBackOff issue, check the command set in the pod is correct or not.
Edith Puclla:
The command is good, it is an echo:
controlplane $ k logs hello3
Hello World
Alok Rahul:
In earlier version of K8s it would not crashloopbackoff, but in recent ones, it would crashloopbackoff if you run them like deployment.
This is why we have resource like jobs and cronjobs for such scenario, hence in such cases use jobs and cronjobs that will execute your task multiple times.