I was trying to measure pod startup time buy running the following:
% kubectl run --image busybox --attach test -- date
error: timed out waiting for the condition
At first it seems like this command takes a long time to start the pod. However if you run kubectl get pods
while it is running you see something interesting.
At first the command succeeds:
% kubectl get pods
NAME READY STATUS RESTARTS AGE
test 0/1 Completed 0 2s
Then transitions to CrashLoopBackOff
.
% kubectl get pods
NAME READY STATUS RESTARTS AGE
test 0/1 CrashLoopBackOff 1 7s
The logs show that the command ran successfully.
% kubectl logs test
Thu Jan 27 15:02:36 UTC 2022
It is unclear to me why the pod is transitioning from Completed
to CrashLoopBackOff
. Is there a way to make kubectl
do the right thing in this scenario?
The best work-around I have found so far is to use a slower command and subtract the delay from my testing.
% kubectl run --image busybox --attach test -- sleep 10