Skip to content

Commit cfc5ea3

Browse files
authored
Merge pull request #46529 from sftim/20240524_improve_pod_lifecycle
Improve pod lifecycle concept page
2 parents ddad6bd + 2e638c3 commit cfc5ea3

File tree

1 file changed

+48
-29
lines changed

1 file changed

+48
-29
lines changed

content/en/docs/concepts/workloads/pods/pod-lifecycle.md

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ in the `Pending` [phase](#pod-phase), moving through `Running` if at least one
1111
of its primary containers starts OK, and then through either the `Succeeded` or
1212
`Failed` phases depending on whether any container in the Pod terminated in failure.
1313

14+
Like individual application containers, Pods are considered to be relatively
15+
ephemeral (rather than durable) entities. Pods are created, assigned a unique
16+
ID ([UID](/docs/concepts/overview/working-with-objects/names/#uids)), and scheduled
17+
to run on nodes where they remain until termination (according to restart policy) or
18+
deletion.
19+
If a {{< glossary_tooltip term_id="node" >}} dies, the Pods running on (or scheduled
20+
to run on) that node are [marked for deletion](#pod-garbage-collection). The control
21+
plane marks the Pods for removal after a timeout period.
22+
23+
<!-- body -->
24+
25+
## Pod lifetime
26+
1427
Whilst a Pod is running, the kubelet is able to restart containers to handle some
1528
kind of faults. Within a Pod, Kubernetes tracks different container
1629
[states](#container-states) and determines what action to take to make the Pod
@@ -21,32 +34,48 @@ status for a Pod object consists of a set of [Pod conditions](#pod-conditions).
2134
You can also inject [custom readiness information](#pod-readiness-gate) into the
2235
condition data for a Pod, if that is useful to your application.
2336

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

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

30-
## Pod lifetime
51+
### Pods and fault recovery {#pod-fault-recovery}
3152

32-
Like individual application containers, Pods are considered to be relatively
33-
ephemeral (rather than durable) entities. Pods are created, assigned a unique
34-
ID ([UID](/docs/concepts/overview/working-with-objects/names/#uids)), and scheduled
35-
to nodes where they remain until termination (according to restart policy) or
36-
deletion.
37-
If a {{< glossary_tooltip term_id="node" >}} dies, the Pods scheduled to that node
38-
are [scheduled for deletion](#pod-garbage-collection) after a timeout period.
53+
If one of the containers in the Pod fails, then Kubernetes may try to restart that
54+
specific container.
55+
Read [How Pods handle problems with containers](#container-restarts) to learn more.
3956

40-
Pods do not, by themselves, self-heal. If a Pod is scheduled to a
41-
{{< glossary_tooltip text="node" term_id="node" >}} that then fails, the Pod is deleted; likewise,
42-
a Pod won't survive an eviction due to a lack of resources or Node maintenance. Kubernetes uses a
43-
higher-level abstraction, called a
57+
Pods can however fail in a way that the cluster cannot recover from, and in that case
58+
Kubernetes does not attempt to heal the Pod further; instead, Kubernetes deletes the
59+
Pod and relies on other components to provide automatic healing.
60+
61+
If a Pod is scheduled to a {{< glossary_tooltip text="node" term_id="node" >}} and that
62+
node then fails, the Pod is treated as unhealthy and Kubernetes eventually deletes the Pod.
63+
A Pod won't survive an {{< glossary_tooltip text="eviction" term_id="eviction" >}} due to
64+
a lack of resources or Node maintenance.
65+
66+
Kubernetes uses a higher-level abstraction, called a
4467
{{< glossary_tooltip term_id="controller" text="controller" >}}, that handles the work of
4568
managing the relatively disposable Pod instances.
4669

4770
A given Pod (as defined by a UID) is never "rescheduled" to a different node; instead,
48-
that Pod can be replaced by a new, near-identical Pod, with even the same name if
49-
desired, but with a different UID.
71+
that Pod can be replaced by a new, near-identical Pod. If you make a replacement Pod, it can
72+
even have same name (as in `.metadata.name`) that the old Pod had, but the replacement
73+
would have a different `.metadata.uid` from the old Pod.
74+
75+
Kubernetes does not guarantee that a replacement for an existing Pod would be scheduled to
76+
the same node as the old Pod that was being replaced.
77+
78+
### Associated lifetimes
5079

5180
When something is said to have the same lifetime as a Pod, such as a
5281
{{< glossary_tooltip term_id="volume" text="volume" >}},
@@ -55,10 +84,7 @@ exists. If that Pod is deleted for any reason, and even if an identical replacem
5584
is created, the related thing (a volume, in this example) is also destroyed and
5685
created anew.
5786

58-
{{< figure src="/images/docs/pod.svg" title="Pod diagram" class="diagram-medium" >}}
59-
60-
A multi-container Pod that contains a file puller and a
61-
web server that uses a persistent volume for shared storage between the containers.
87+
{{< figure src="/images/docs/pod.svg" title="Figure 1." class="diagram-medium" caption="A multi-container Pod that contains a file puller [sidecar](/docs/concepts/workloads/pods/sidecar-containers/) and a web server. The Pod uses an [ephemeral `emptyDir` volume](/docs/concepts/storage/volumes/#emptydir) for shared storage between the containers." >}}
6288

6389
## Pod phase
6490

@@ -348,13 +374,6 @@ after successful sandbox creation and network configuration by the runtime
348374
plugin). For a Pod without init containers, the kubelet sets the `Initialized`
349375
condition to `True` before sandbox creation and network configuration starts.
350376

351-
### Pod scheduling readiness {#pod-scheduling-readiness-gate}
352-
353-
{{< feature-state for_k8s_version="v1.26" state="alpha" >}}
354-
355-
See [Pod Scheduling Readiness](/docs/concepts/scheduling-eviction/pod-scheduling-readiness/)
356-
for more information.
357-
358377
## Container probes
359378

360379
A _probe_ is a diagnostic performed periodically by the [kubelet](/docs/reference/command-line-tools-reference/kubelet/)

0 commit comments

Comments
 (0)