Skip to content

Commit 2b4b4b4

Browse files
author
Tim Bannister
committed
Improve docs for Pods
- Add glossary entry for sidecar container - Revise glossary entry for init container to match - Revise the Pod concept overview - Reorder pages in that section
1 parent df0e89f commit 2b4b4b4

File tree

5 files changed

+102
-53
lines changed

5 files changed

+102
-53
lines changed

content/en/docs/concepts/workloads/pods/_index.md

Lines changed: 75 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ containers which are relatively tightly coupled.
1919
In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host.
2020

2121
As well as application containers, a Pod can contain
22-
[init containers](/docs/concepts/workloads/pods/init-containers/) that run
22+
{{< glossary_tooltip text="init containers" term_id="init-container" >}} that run
2323
during Pod startup. You can also inject
24-
[ephemeral containers](/docs/concepts/workloads/pods/ephemeral-containers/)
25-
for debugging if your cluster offers this.
24+
{{< glossary_tooltip text="ephemeral containers" term_id="ephemeral-container" >}}
25+
for debugging a running Pod.
2626

2727
2828

@@ -39,6 +39,26 @@ further sub-isolations applied.
3939

4040
A Pod is similar to a set of containers with shared namespaces and shared filesystem volumes.
4141

42+
Pods in a Kubernetes cluster are used in two main ways:
43+
44+
* **Pods that run a single container**. The "one-container-per-Pod" model is the
45+
most common Kubernetes use case; in this case, you can think of a Pod as a
46+
wrapper around a single container; Kubernetes manages Pods rather than managing
47+
the containers directly.
48+
* **Pods that run multiple containers that need to work together**. A Pod can
49+
encapsulate an application composed of
50+
[multiple co-located containers](#how-pods-manage-multiple-containers) that are
51+
tightly coupled and need to share resources. These co-located containers
52+
form a single cohesive unit.
53+
54+
Grouping multiple co-located and co-managed containers in a single Pod is a
55+
relatively advanced use case. You should use this pattern only in specific
56+
instances in which your containers are tightly coupled.
57+
58+
You don't need to run multiple containers to provide replication (for resilience
59+
or capacity); if you need multiple replicas, see
60+
[Workload management](/docs/concepts/workloads/controllers/).
61+
4262
## Using Pods
4363

4464
The following is an example of a Pod which consists of a container running the image `nginx:1.14.2`.
@@ -61,26 +81,6 @@ term_id="deployment" >}} or {{< glossary_tooltip text="Job" term_id="job" >}}.
6181
If your Pods need to track state, consider the
6282
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}} resource.
6383

64-
Pods in a Kubernetes cluster are used in two main ways:
65-
66-
* **Pods that run a single container**. The "one-container-per-Pod" model is the
67-
most common Kubernetes use case; in this case, you can think of a Pod as a
68-
wrapper around a single container; Kubernetes manages Pods rather than managing
69-
the containers directly.
70-
* **Pods that run multiple containers that need to work together**. A Pod can
71-
encapsulate an application composed of multiple co-located containers that are
72-
tightly coupled and need to share resources. These co-located containers
73-
form a single cohesive unit of service—for example, one container serving data
74-
stored in a shared volume to the public, while a separate _sidecar_ container
75-
refreshes or updates those files.
76-
The Pod wraps these containers, storage resources, and an ephemeral network
77-
identity together as a single unit.
78-
79-
{{< note >}}
80-
Grouping multiple co-located and co-managed containers in a single Pod is a
81-
relatively advanced use case. You should use this pattern only in specific
82-
instances in which your containers are tightly coupled.
83-
{{< /note >}}
8484

8585
Each Pod is meant to run a single instance of a given application. If you want to
8686
scale your application horizontally (to provide more overall resources by running
@@ -93,36 +93,10 @@ See [Pods and controllers](#pods-and-controllers) for more information on how
9393
Kubernetes uses workload resources, and their controllers, to implement application
9494
scaling and auto-healing.
9595

96-
### How Pods manage multiple containers
97-
98-
Pods are designed to support multiple cooperating processes (as containers) that form
99-
a cohesive unit of service. The containers in a Pod are automatically co-located and
100-
co-scheduled on the same physical or virtual machine in the cluster. The containers
101-
can share resources and dependencies, communicate with one another, and coordinate
102-
when and how they are terminated.
103-
104-
For example, you might have a container that
105-
acts as a web server for files in a shared volume, and a separate "sidecar" container
106-
that updates those files from a remote source, as in the following diagram:
107-
108-
{{< figure src="/images/docs/pod.svg" alt="Pod creation diagram" class="diagram-medium" >}}
109-
110-
Some Pods have {{< glossary_tooltip text="init containers" term_id="init-container" >}}
111-
as well as {{< glossary_tooltip text="app containers" term_id="app-container" >}}.
112-
By default, init containers run and complete before the app containers are started.
113-
114-
{{< feature-state for_k8s_version="v1.29" state="beta" >}}
115-
116-
Enabled by default, the `SidecarContainers` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
117-
allows you to specify `restartPolicy: Always` for init containers.
118-
Setting the `Always` restart policy ensures that the init containers where you set it are
119-
kept running during the entire lifetime of the Pod.
120-
See [Sidecar containers and restartPolicy](/docs/concepts/workloads/pods/init-containers/#sidecar-containers-and-restartpolicy)
121-
for more details.
122-
12396
Pods natively provide two kinds of shared resources for their constituent containers:
12497
[networking](#pod-networking) and [storage](#pod-storage).
12598

99+
126100
## Working with Pods
127101

128102
You'll rarely create individual Pods directly in Kubernetes—even singleton Pods. This
@@ -343,6 +317,57 @@ The `spec` of a static Pod cannot refer to other API objects
343317
{{< glossary_tooltip text="Secret" term_id="secret" >}}, etc).
344318
{{< /note >}}
345319

320+
## Pods with multiple containers {#how-pods-manage-multiple-containers}
321+
322+
Pods are designed to support multiple cooperating processes (as containers) that form
323+
a cohesive unit of service. The containers in a Pod are automatically co-located and
324+
co-scheduled on the same physical or virtual machine in the cluster. The containers
325+
can share resources and dependencies, communicate with one another, and coordinate
326+
when and how they are terminated.
327+
328+
329+
Pods in a Kubernetes cluster are used in two main ways:
330+
331+
* **Pods that run a single container**. The "one-container-per-Pod" model is the
332+
most common Kubernetes use case; in this case, you can think of a Pod as a
333+
wrapper around a single container; Kubernetes manages Pods rather than managing
334+
the containers directly.
335+
* **Pods that run multiple containers that need to work together**. A Pod can
336+
encapsulate an application composed of
337+
multiple co-located containers that are
338+
tightly coupled and need to share resources. These co-located containers
339+
form a single cohesive unit of service—for example, one container serving data
340+
stored in a shared volume to the public, while a separate
341+
{{< glossary_tooltip text="sidecar container" term_id="sidecar-container" >}}
342+
refreshes or updates those files.
343+
The Pod wraps these containers, storage resources, and an ephemeral network
344+
identity together as a single unit.
345+
346+
For example, you might have a container that
347+
acts as a web server for files in a shared volume, and a separate
348+
[sidecar container](/docs/concepts/workloads/pods/sidecar-containers/)
349+
that updates those files from a remote source, as in the following diagram:
350+
351+
{{< figure src="/images/docs/pod.svg" alt="Pod creation diagram" class="diagram-medium" >}}
352+
353+
Some Pods have {{< glossary_tooltip text="init containers" term_id="init-container" >}}
354+
as well as {{< glossary_tooltip text="app containers" term_id="app-container" >}}.
355+
By default, init containers run and complete before the app containers are started.
356+
357+
You can also have [sidecar containers](/docs/concepts/workloads/pods/sidecar-containers/)
358+
that provide auxiliary services to the main application Pod (for example: a service mesh).
359+
360+
{{< feature-state for_k8s_version="v1.29" state="beta" >}}
361+
362+
Enabled by default, the `SidecarContainers` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
363+
allows you to specify `restartPolicy: Always` for init containers.
364+
Setting the `Always` restart policy ensures that the containers where you set it are
365+
treated as _sidecars_ that are kept running during the entire lifetime of the Pod.
366+
Containers that you explicitly define as sidecar containers
367+
start up before the main application Pod and remain running until the Pod is
368+
shut down.
369+
370+
346371
## Container probes
347372

348373
A _probe_ is a diagnostic performed periodically by the kubelet on a container. To perform a diagnostic, the kubelet can invoke different actions:

content/en/docs/concepts/workloads/pods/disruptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ reviewers:
55
- davidopp
66
title: Disruptions
77
content_type: concept
8-
weight: 60
8+
weight: 70
99
---
1010

1111

content/en/docs/concepts/workloads/pods/ephemeral-containers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ reviewers:
44
- yujuhong
55
title: Ephemeral Containers
66
content_type: concept
7-
weight: 80
7+
weight: 60
88
---
99

1010

content/en/docs/reference/glossary/init-container.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date: 2018-04-12
55
full_link:
66
short_description: >
77
One or more initialization containers that must run to completion before any app containers run.
8-
8+
full_link: /docs/concepts/workloads/pods/init-containers/
99
aka:
1010
tags:
1111
- fundamental
@@ -15,3 +15,7 @@ tags:
1515
1616

1717
Initialization (init) containers are like regular app containers, with one difference: init containers must run to completion before any app containers can start. Init containers run in series: each init container must run to completion before the next init container begins.
18+
19+
Unlike {{< glossary_tooltip text="sidecar containers" term_id="sidecar-container" >}}, init containers do not remain running after Pod startup.
20+
21+
For more information, read [init containers](/docs/concepts/workloads/pods/init-containers/).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Sidecar Container
3+
id: sidecar-container
4+
date: 2018-04-12
5+
full_link:
6+
short_description: >
7+
An auxilliary container that stays running throughout the lifecycle of a Pod.
8+
full_link: /docs/concepts/workloads/pods/sidecar-containers/
9+
tags:
10+
- fundamental
11+
---
12+
One or more {{< glossary_tooltip text="containers" term_id="container" >}} that are typically started before any app containers run.
13+
14+
15+
16+
Sidecar containers are like regular app containers, but with a different purpose: the sidecar provides a Pod-local service to the main app container.
17+
Unlike {{< glossary_tooltip text="init containers" term_id="init-container" >}}, sidecar containers
18+
continue running after Pod startup.
19+
20+
Read [Sidecar containers](/docs/concepts/workloads/pods/sidecar-containers/) for more information.

0 commit comments

Comments
 (0)