無法啟動 busybox Pod

無法啟動 busybox Pod

如果我像這樣啟動 Kubernetes pod,它會失敗:

k run bb --image=busybox
k describe pod bb

...
Events:
  Type     Reason   Age                     From     Message
  ----     ------   ----                    ----     -------
  Normal   Pulling  14m (x35 over 164m)     kubelet  Pulling image "busybox"
  Warning  BackOff  4m23s (x736 over 164m)  kubelet  Back-off restarting failed container

是什麼原因?

這些run命令對於圖像效果很好nginx

答案1

busybox不是伺服器。它不會啟動無休止的“監聽輸入”循環。

影像也會發生同樣的情況alpine

但你可以像這樣創造一個無限循環:

apiVersion: v1
kind: Pod
metadata:
  name: bb
spec:
  containers:
  - image: busybox
    command: ['sh', '-c', 'while true; do date; sleep 3; done']
    name: bb
k apply -f bb.yaml
k describe pod bb

...
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  6s    default-scheduler  Successfully assigned default/bb to minikube-m02
  Normal  Pulling    5s    kubelet            Pulling image "busybox"
  Normal  Pulled     3s    kubelet            Successfully pulled image "busybox" in 2.256262371s
  Normal  Created    3s    kubelet            Created container bb
  Normal  Started    3s    kubelet            Started container bb

並且可以看到日誌:

guettli@p15:~/.kube$ k logs bb 

Fri Apr  8 20:38:30 UTC 2022
Fri Apr  8 20:38:33 UTC 2022
Fri Apr  8 20:38:36 UTC 2022

相關內容