@@ -19,10 +19,10 @@ containers which are relatively tightly coupled.
19
19
In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host.
20
20
21
21
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
23
23
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 .
26
26
27
27
28
28
@@ -39,6 +39,26 @@ further sub-isolations applied.
39
39
40
40
A Pod is similar to a set of containers with shared namespaces and shared filesystem volumes.
41
41
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
+
42
62
## Using Pods
43
63
44
64
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" >}}.
61
81
If your Pods need to track state, consider the
62
82
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}} resource.
63
83
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 >}}
84
84
85
85
Each Pod is meant to run a single instance of a given application. If you want to
86
86
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
93
93
Kubernetes uses workload resources, and their controllers, to implement application
94
94
scaling and auto-healing.
95
95
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
-
123
96
Pods natively provide two kinds of shared resources for their constituent containers:
124
97
[ networking] ( #pod-networking ) and [ storage] ( #pod-storage ) .
125
98
99
+
126
100
## Working with Pods
127
101
128
102
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
343
317
{{< glossary_tooltip text="Secret" term_id="secret" >}}, etc).
344
318
{{< /note >}}
345
319
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
+
346
371
## Container probes
347
372
348
373
A _ probe_ is a diagnostic performed periodically by the kubelet on a container. To perform a diagnostic, the kubelet can invoke different actions:
0 commit comments