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

配置livenessProbe与readinessProbe时无法创建指定文件,请求协助排查

Troubleshooting Missing /tmp/healthy File for Kubernetes Liveness/Readiness Probes

Hey there, let's work through why your liveness probe is failing because it can't find /tmp/healthy—I've run into similar headaches before, so let's break this down step by step:

1. Confirm the touch Command Is Actually Running

First, let's make sure the command that creates your marker file is executing successfully:

  • Pull your container logs to check for startup script errors:
    kubectl logs <your-pod-name>
    
    If an earlier command in your startup script fails and exits, the touch /tmp/healthy command might never get to run. Look for error messages that halt script execution.
  • Manually jump into the container to test the command directly:
    kubectl exec -it <your-pod-name> -- /bin/sh
    # Once inside, run these commands:
    touch /tmp/healthy
    ls /tmp
    
    If this fails, you'll see an explicit error (like permission denied) pointing to the root cause. While /tmp is usually world-writable, some hardened images or Pod securityContext settings might restrict write access for non-root users.

2. Fix Probe Timing Mismatches

A super common issue is the probe checking too early before your container finishes initializing:

  • Look at your probe's initialDelaySeconds value. If it's set to a tiny number (like 0 or 1), the probe starts checking before your touch command has a chance to run. Try bumping this up to give your container time to set up—start with 30 seconds and adjust as needed:
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 30
      periodSeconds: 10
    

3. Double-Check Paths for Typos

It sounds trivial, but typos are easy to miss! Verify:

  • The path in your probe (/tmp/healthy) matches exactly what's in your touch command. No mix-ups like /temp/healthy (a common typo between "tmp" and "temp").
  • You're using absolute paths for both the touch command and probe check. Relative paths can break if your container's working directory isn't what you expect.

4. Rule Out File Cleanup Processes

In some setups, cleanup scripts or sidecar containers might be deleting files in /tmp. If your Pod has multiple containers, check if any of them are modifying the /tmp directory. You can also temporarily add a sleep 60 after the touch command to see if the file exists briefly before being deleted.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:45:58