How can I tell if a Kubernetes pod is running out of PIDs?

November 19, 2026 4 answers
Asked by 6r!mossyhinge_417

A pod that launches command-line tools is showing several unrelated errors, including a fork failure, but its HTTP liveness probe still passes. Could PID exhaustion explain this, and how would I confirm and fix it?

Answers

NimbleTurnstile

It could. A fork or exec error saying resource temporarily unavailable is a useful clue, though it is not proof of a pod PID limit by itself. Once process creation fails, different components can report very different secondary errors.

Check pids.current and pids.max in the pod's cgroup. On cgroup v2 these are usually under /sys/fs/cgroup. On v1, look under /sys/fs/cgroup/pids. If current is at max, inspect the process list for old or repeatedly accumulating commands. If you can't start a shell or diagnostic command in the pod, you may need to inspect it from the node.

p.628+gasketfinch:

Check before restarting if you can do so safely. A restart may restore service, but it also clears the process state you want to inspect.

Reply to this answer
n.693~ferrulecrayon

Look closely at subprocess cleanup. A timeout on a shell wrapper does not necessarily stop the commands that wrapper launched. They can keep running after the wrapper exits, so a small leak on each recurring job can add up.

Give each execution a deadline and arrange to terminate the whole process group on cancellation, not just the direct child. Also investigate why the commands hang in the first place, such as an authentication or permissions problem. Make sure exited children are reaped too.

Reply to this answer
m.418!quavdelo

An HTTP liveness endpoint can stay green because answering a request doesn't necessarily require starting a new process. It tells you the handler is responsive, not that the pod can still launch its tools.

A minimal exec liveness probe can catch this failure because the probe itself needs to start a process. Keep it simple, allow a few consecutive failures, and remember that it adds a process launch on every probe. A restart is a recovery measure, not a fix for whatever is leaking processes.

Ruvlano-9t:

PID usage monitoring can give you warning before the limit is reached. The exec probe is more of a backstop once process creation is already failing.

Reply to this answer
Norlixo+5v

Check the kubelet's podPidsLimit setting as well. A deliberate limit can contain the damage from a runaway pod, but raising it alone just gives a leak more room to grow. Compare the limit with the workload's normal process and thread usage before changing it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions