Kubernetes Blog
Follow
Kubernetes v1.34: Finer-Grained Control Over Container Restarts
Kubernetes 1.34 introduces an alpha feature called Container Restart Policy and Rules. This feature allows individual control over container restarts within a Pod, overriding the Pod's global restart policy. It also enables conditional restarts for containers based on their exit codes. Previously, all containers in a Pod shared a single restart policy. This limitation prevented scenarios like having an init container that runs only once while the main application container always restarts. The new feature, activated by the ContainerRestartRules alpha feature gate, addresses this by allowing per-container restart policies and rules. Use cases include in-place restarts for training jobs with specific exit codes, try-once init containers, and Pods with multiple containers having different restart needs. To use this feature, the ContainerRestartRules feature gate must be enabled. Examples demonstrate how to configure restarts based on specific exit codes, implement try-once init containers, and assign different restart policies to multiple containers. This alpha feature welcomes community feedback and is developed by SIG Node. Future plans include support for restarting entire Pods.