Skip to content

[Docs] Clarify Pod restartPolicy behavior in “Always” vs “OnFailure” scenarios #51757

@ashutosh-engineer

Description

@ashutosh-engineer

Problem

The Kubernetes documentation for restartPolicy in Pods (https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) does not clearly explain the differences in container restart behavior between Always, OnFailure, and Never.

New users are often confused when a pod restarts even after exit code 0 or doesn't restart despite an error, especially when used with Deployments or Jobs.


Steps to Reproduce

  1. Create a Pod with restartPolicy: OnFailure
  2. Run a container that exits with code 0
  3. Notice the pod does not restart
  4. Change it to exit with code 1 → Now it restarts

Expected Addition to Docs

  • Table comparing:
    • Exit code vs Restart behavior
    • Behavior under different controllers (e.g., Deployment, Job)
  • Add concrete YAML examples
  • Link to kubelet behavior references

Suggested Fix

I'd like to improve the docs page with:

  • A comparison table
  • Clear examples of OnFailure, Always, Never
  • Add links to the underlying kubelet logic

Let me know if this would be accepted — happy to draft the PR!

Labels: documentation, good first issue, help wanted

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/nodeCategorizes an issue or PR as relevant to SIG Node.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions