⎈ k8s knowledge compiler

Pod Lifecycle [page]deterministic

concepts

This page describes the lifecycle of a Pod. Pods follow a defined lifecycle, starting in the `Pending` [phase](#pod-phase), moving through `Running` if at least one of its primary containers starts OK, and then through either the `Succeeded` or `Failed` phases depending on whether any container in the Pod terminated in failure.

While a Pod runs, the kubelet manages containers and translates the Pod's spec for the container runtime. The kubelet also manages executing [probes](#container-probes) that track the health of your application.

Like individual application containers, Pods are considered to be relatively ephemeral (rather than durable) entities. Pods are created, assigned a unique ID ([UID](/docs/concepts/overview/working-with-objects/names/#uids)), and scheduled to run on nodes where they remain until termination (according to restart policy) or deletion. If a [node](#gloss:node) dies, the Pods running on (or scheduled to run on) that node are [marked for deletion](#pod-garbage-collection). The control plane marks the Pods for removal after a timeout period.

## Pod lifetime

While a Pod is running, the kubelet is able to restart containers to handle some kind of faults. Within a Pod, Kubernetes tracks different container [states](#container-states) and determines what action to take to make the Pod healthy again. This is done in a [polling loop](/docs/reference/node/kubelet-sync-loop/) that periodically reconciles the desired state (a Pod spec) with the actual state of the running containers.

In the Kubernetes API, Pods have both a specification and an actual status. The status for a Pod object consists of a set of [Pod conditions](#pod-conditions). You can also inject [custom readiness information](#pod-readiness-gate) into the condition data for a Pod, if that is useful to your application.

Pods are only [scheduled](/docs/concepts/scheduling-eviction/) once in their lifetime; assigning a Pod to a specific node is called _binding_, and the process of selecting which node to use is called _scheduling_. Once a Pod has been scheduled and is bound to a node, Kubernetes tries to run that Pod on the node. The Pod runs on that node until it stops, or until the Pod is [terminated](#pod-termination); if Kubernetes isn't able to start the Pod on the selected node (for example, if the node crashes before the Pod starts), then that particular Pod never starts.

You can use [Pod Scheduling Readiness](/docs/concepts/scheduling-eviction/pod-scheduling-readiness/) to delay scheduling for a Pod until all its _scheduling gates_ are removed. For example, you might want to define a set of Pods but only trigger scheduling once all the Pods have been created.

### Pods and fault recovery {#pod-fault-recovery}

If one of the containers in the Pod fails, then Kubernetes may try to restart that specific container. Read [How Pods handle problems with containers](#container-restarts) to learn more.

Pods can however fail in a way that the cluster cannot recover from, and in that case Kubernetes does not attempt to heal the Pod further; instead, Kubernetes deletes the Pod and relies on other components to provide automatic healing.

If a Pod is scheduled to a [node](#gloss:node) and that node then fails, the Pod is treated as unhealthy and Kubernetes eventually deletes the Pod. A Pod won't survive an [eviction](#gloss:eviction) due to a lack of resources or Node maintenance.

Kubernetes uses a higher-level abstraction, called a [controller](#gloss:controller), that handles the work of managing the relatively disposable Pod instances.

A given Pod (as defined by a UID) is never "rescheduled" to a different node; instead, that Pod can be replaced by a new, near-identical Pod. If you make a replacement Pod, it can even have same name (as in `.metadata.name`) that the old Pod had, but the replacement would have a different `.metadata.uid` from the old Pod.

Kubernetes does not guarantee that a replacement for an existing Pod would be schedu …(trimmed)

Sources

concepts/workloads/pods/pod-lifecycle.md · docPod Lifecycle

Related (25)

references Nodenode conf=1
references Evictioneviction conf=1
references Controllercontroller conf=1
references Volumevolume conf=1
references Mirror Podmirror Pods conf=1
references kube-schedulerscheduler conf=1
references Container Runtimecontainer runtime conf=1
references SecretSecret conf=1
references Init Containerinit containers conf=1
references Sidecar Containersidecar container conf=1
references App Containerapp containers conf=1
references Operator patternoperators conf=1
references Container Runtime Interface (CRI)cri conf=1
references Conditionconditions conf=1
references Kubeletkubelet conf=1
references EndpointSliceEndpointSlice conf=1
references API serverAPI Server conf=1
references ServiceService conf=1
references Selectorselector conf=1
references ReplicaSetReplicaSets conf=1
part_of Pod lifetimedescribes conf=1
part_of Pod phasedescribes conf=1
part_of Container statesdescribes conf=1
part_of Pod conditionsdescribes conf=1

← all Docs