By starting deployment with busybox as an image:
kubectl create deployment test-deployment --image=busybox --dry-run=client --output=yaml > test-deployment.yaml
kubectl apply -f test-deployment.yaml
POD will end up in error state:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 34s default-scheduler Successfully assigned default/test-deployment-6b4c9bbbc7-mfk5m to worker01
Normal Pulled 29s kubelet Successfully pulled image "busybox" in 3.907s (3.907s including waiting)
Normal Pulled 27s kubelet Successfully pulled image "busybox" in 1.148s (1.148s including waiting)
Normal Pulling 10s (x3 over 33s) kubelet Pulling image "busybox"
Normal Created 9s (x3 over 29s) kubelet Created container busybox
Normal Started 9s (x3 over 29s) kubelet Started container busybox
Normal Pulled 9s kubelet Successfully pulled image "busybox" in 1.294s (1.294s including waiting)
Warning BackOff 8s (x3 over 26s) kubelet Back-off restarting failed container busybox in pod test-deployment-6b4c9bbbc7-mfk5m_default(7cb42324-eb2a-421d-907c-d20fc412cd4a)
If I replace busybox image with eg. nginx - no problems:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 71s default-scheduler Successfully assigned default/test-deployment-5746d5bc6f-svskj to worker01
Normal Pulling 70s kubelet Pulling image "nginx"
Normal Pulled 50s kubelet Successfully pulled image "nginx" in 19.483s (19.483s including waiting)
Normal Created 50s kubelet Created container nginx
Normal Started 49s kubelet Started container nginx
Workaround: To overcome this problem it is required to add extra command to the deployment:
spec:
containers:
- image: busybox
command: ['sh', '-c', 'while true; do date; sleep 3; done'] <--- HERE
name: busybox
Question: Why containers created with busybox require that endless loop to keep it alive WHEREAS eg. nginx does not require any extra commands/parameters?
Could it be because by default nginx image is running nginx/HTTP service and this is replacement for endless loop/container keep alive?
docker run busybox
). Pods (containers in general, really) are generally meant to run some sort of persistent service (like a web server, database, etc).