Guides

How to get started, and achieve tasks, using Kubernetes

Edit This Page

The Lifecycle of a Pod

Updated: 4/14/2015

This document covers the lifecycle of a pod. It is not an exhaustive document, but an introduction to the topic.

Pod Phase

As consistent with the overall API convention, phase is a simple, high-level summary of the phase of the lifecycle of a pod. It is not intended to be a comprehensive rollup of observations of container-level or even pod-level conditions or other state, nor is it intended to be a comprehensive state machine.

The number and meanings of PodPhase values are tightly guarded. Other than what is documented here, nothing should be assumed about pods with a given PodPhase.

Pod Conditions

A pod containing containers that specify readiness probes will also report the Ready condition. Condition status values may be True, False, or Unknown.

Container Probes

A Probe is a diagnostic performed periodically by the kubelet on a container. Specifically the diagnostic is one of three Handlers:

Each probe will have one of three results:

Currently, the kubelet optionally performs two independent diagnostics on running containers which trigger action:

Container Statuses

More detailed information about the current (and previous) container statuses can be found in ContainerStatuses. The information reported depends on the current ContainerState, which may be Waiting, Running, or Terminated.

RestartPolicy

The possible values for RestartPolicy are Always, OnFailure, or Never. If RestartPolicy is not set, the default value is Always. RestartPolicy applies to all containers in the pod. RestartPolicy only refers to restarts of the containers by the Kubelet on the same node. Failed containers that are restarted by Kubelet, are restarted with an exponential back-off delay, the delay is in multiples of sync-frequency 0, 1x, 2x, 4x, 8x … capped at 5 minutes and is reset after 10 minutes of successful execution. As discussed in the pods document, once bound to a node, a pod will never be rebound to another node. This means that some kind of controller is necessary in order for a pod to survive node failure, even if just a single pod at a time is desired.

Three types of controllers are currently available:

ReplicationController is only appropriate for pods with RestartPolicy = Always. Job is only appropriate for pods with RestartPolicy equal to OnFailure or Never.

All 3 types of controllers contain a PodTemplate, which has all the same fields as a Pod. It is recommended to create the appropriate controller and let it create pods, rather than to directly create pods yourself. That is because pods alone are not resilient to machine failures, but Controllers are.

Pod lifetime

In general, pods which are created do not disappear until someone destroys them. This might be a human or a ReplicationController, or another controller. The only exception to this rule is that pods with a PodPhase of Succeeded or Failed for more than some duration (determined by the master) will expire and be automatically reaped.

If a node dies or is disconnected from the rest of the cluster, some entity within the system (call it the NodeController for now) is responsible for applying policy (e.g. a timeout) and marking any pods on the lost node as Failed.

Examples

Analytics