You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
init containers are not continuously running alongside the main containers.
70
+
71
+
Init containers run to completion sequentially, and the main container does not start
72
+
until all the init containers have successfully completed.
73
+
74
+
init containers do not support `lifecycle`, `livenessProbe`, `readinessProbe`, or
75
+
`startupProbe` whereas sidecar containers support all these [probes](/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe) to control their lifecycle.
76
+
77
+
Init containers share the same resources (CPU, memory, network) with the main application
78
+
containers but do not interact directly with them. They can, however, use shared volumes
79
+
for data exchange.
80
+
59
81
## Using init containers
60
82
61
83
Because init containers have separate images from app containers, they
@@ -289,51 +311,9 @@ The Pod which is already running correctly would be killed by `activeDeadlineSec
289
311
The name of each app and init container in a Pod must be unique; a
290
312
validation error is thrown for any container sharing a name with another.
Given the ordering and execution for init containers, the following rules
316
+
Given the order of execution for init, sidecar and app containers, the following rules
337
317
for resource usage apply:
338
318
339
319
* The highest of any particular resource request or limit defined on all init
@@ -354,6 +334,10 @@ limit.
354
334
Pod level control groups (cgroups) are based on the effective Pod request and
355
335
limit, the same as the scheduler.
356
336
337
+
{{< comment >}}
338
+
This section also present under [sidecar containers](/docs/concepts/workloads/pods/sidecar-containers/) page.
339
+
If you're editing this section, change both places.
340
+
{{< /comment >}}
357
341
358
342
### Pod restart reasons
359
343
@@ -373,7 +357,9 @@ Kubernetes, consult the documentation for the version you are using.
373
357
374
358
## {{% heading "whatsnext" %}}
375
359
376
-
* Read about [creating a Pod that has an init container](/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container)
377
-
* Learn how to [debug init containers](/docs/tasks/debug/debug-application/debug-init-containers/)
378
-
* Read about an overview of [kubelet](/docs/reference/command-line-tools-reference/kubelet/) and [kubectl](/docs/reference/kubectl/)
379
-
* Learn about the [types of probes](/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe): liveness, readiness, startup probe.
360
+
Learn more about the following:
361
+
* [Creating a Pod that has an init container](/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container).
By default, this feature is not available in Kubernetes. To avail this feature, you
61
+
need to enable the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
62
+
named `SidecarContainers`.
63
+
64
+
## Differences from regular containers
65
+
66
+
Sidecar containers run alongside regular containers in the same pod. However, they do not
67
+
execute the primary application logic; instead, they provide supporting functionality to
68
+
the main application.
69
+
70
+
Sidecar containers have their own independent lifecycles. They can be started, stopped,
71
+
and restarted independently of regular containers. This means you can update, scale, or
72
+
maintain sidecar containers without affecting the primary application.
73
+
74
+
Sidecar containers share the same network and storage namespaces with the primary
75
+
container This co-location allows them to interact closely and share resources.
76
+
77
+
## Differences from init containers
78
+
79
+
Sidecar containers work alongside the main container, extending its functionality and
80
+
providing additional services.
81
+
82
+
Sidecar containers run concurrently with the main application container. They are active
83
+
throughout the lifecycle of the pod and can be started and stopped independently of the
84
+
main container. Unlike [init containers](/docs/concepts/workloads/pods/init-containers/),
85
+
sidecar containers support [probes](/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe) to control their lifecycle.
86
+
87
+
These containers can interact directly with the main application containers, sharing
88
+
the same network namespace, filesystem, and environment variables. They work closely
89
+
together to provide additional functionality.
90
+
91
+
## Resource sharing within containers
92
+
93
+
{{< comment >}}
94
+
This section is also present in the [init containers](/docs/concepts/workloads/pods/init-containers/) page.
95
+
If you're editing this section, change both places.
96
+
{{< /comment >}}
97
+
98
+
Given the order of execution for init, sidecar and app containers, the following rules
99
+
for resource usage apply:
100
+
101
+
* The highest of any particular resource request or limit defined on all init
102
+
containers is the *effective init request/limit*. If any resource has no
103
+
resource limit specified this is considered as the highest limit.
104
+
* The Pod's *effective request/limit* for a resource is the sum of
105
+
[pod overhead](/docs/concepts/scheduling-eviction/pod-overhead/) and the higher of:
106
+
* the sum of all non-init containers(app and sidecar containers) request/limit for a
107
+
resource
108
+
* the effective init request/limit for a resource
109
+
* Scheduling is done based on effective requests/limits, which means
110
+
init containers can reserve resources for initialization that are not used
111
+
during the life of the Pod.
112
+
* The QoS (quality of service) tier of the Pod's *effective QoS tier* is the
113
+
QoS tier for all init, sidecar and app containers alike.
114
+
115
+
Quota and limits are applied based on the effective Pod request and
116
+
limit.
117
+
118
+
Pod level control groups (cgroups) are based on the effective Pod request and
119
+
limit, the same as the scheduler.
120
+
121
+
## {{% heading "whatsnext" %}}
122
+
123
+
* Read a blog post on [native sidecar containers](/blog/2023/08/25/native-sidecar-containers/).
124
+
* Read about [creating a Pod that has an init container](/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container).
125
+
* Learn about the [types of probes](/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe): liveness, readiness, startup probe.
126
+
* Learn about [pod overhead](/docs/concepts/scheduling-eviction/pod-overhead/).
0 commit comments