![无法启动 busybox pod](https://linux22.com/image/776323/%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%20busybox%20pod.png)
如果我像这样启动 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