You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

K8s DaemonSet持续重启求助:Pod状态反复切换异常

问题原因及修复方案

你的DaemonSet Pod反复切换状态的核心原因是busybox镜像默认启动的进程会立即退出:

busybox镜像默认会启动sh shell进程,但在K8s的非交互式容器环境中,这个shell没有输入源,会立刻执行完成并退出。而Kubernetes Pod的默认重启策略是Always,因此会不断重启容器,最终导致Pod在Running→Completed→CrashLoopBackOff之间循环往复。

要让Pod稳定处于Running状态,你需要让容器内的进程长期运行。修改你的DaemonSet清单,给容器添加持续运行的命令即可:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ds-test
  labels:
    app: busybox-ds
spec:
  selector:
    matchLabels:
      name: busybox-ds
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 3
  template:
    metadata:
      labels:
        name: busybox-ds
    spec:
      containers:
      - name: busybox-ds
        image: busybox
        command: ["sleep", "infinity"]  # 保持进程长期运行的命令

你也可以用["tail", "-f", "/dev/null"]替代sleep infinity,两者都能让容器进程持续运行,避免Pod退出。

内容的提问来源于stack exchange,提问作者Frendom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 08:45:38