Question
pod.yml
apiVersion: v1
kind: Pod
metadata:
name: hello-pod
labels:
zone: prod
version: v1
spec:
containers:
- name: hello-ctr
image: hello-world:latest
ports:
- containerPort: 8080
kubectl create -f pod.yml
kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-pod 0/1 CrashLoopBackOff 5 5m
Why CrashLoopBackOff
?
Answer
In this case the expected behavior is correct. The hello-world container is
meant to print some messages and then exit after completion. So this is why
you are getting CrashLoopBackOff
-
Kubernetes runs a pod - the container inside runs the expected commands and then exits.
Suddenly there is nothing running underneath - so the pod is ran again -> same
thing happens and the number of restarts
grows.
You can see that inkubectl describe pod
where Terminated
state is visible
and the Reason
for it is status Completed
. If you would choose a container
image which does not exit after completion the pod would be in running state.