Concepts·Certified Kubernetes Administrator
Sidecar Containers
An init container with restartPolicy: Always is not an init container. It keeps running beside the main container - started=true and ready=true at the same instant - and it lives in the initContainers list anyway.
Workloads Guide 32 of 103 Intermediate
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 14 min
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when a helper container has to be running before the app starts and stay running beside it. This matters because one line - restartPolicy: Always on an init container - turns it into a sidecar with guarantees an ordinary container in the same Pod does not get.
- watching an ordinary init container run and finish
- adding
restartPolicy: Alwaysto that same entry and seeing it start and stay - reading the three guarantees that being in the initContainers list actually buys
Before you start
- guide 31 - this is the same field with one line added, and the contrast is the guide.
-
An init container finishes
-
One line changes what it is
-
Why it was worth a new feature