From 404f816de646a49454e4b007e7abfeadb7fe7819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Thu, 23 Oct 2025 10:06:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=EF=B8=8F=20Add=20a=20couple=20of=20sl?= =?UTF-8?q?ides=20about=20sidecars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slides/k8s/volumes.md | 75 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/slides/k8s/volumes.md b/slides/k8s/volumes.md index b2363c5b..159b7ad5 100644 --- a/slides/k8s/volumes.md +++ b/slides/k8s/volumes.md @@ -441,22 +441,6 @@ spec: --- -## Other uses of init containers - -- Load content - -- Generate configuration (or certificates) - -- Database migrations - -- Waiting for other services to be up - - (to avoid flurry of connection errors in main container) - -- etc. - ---- - ## Volume lifecycle - The lifecycle of a volume is linked to the pod's lifecycle @@ -471,6 +455,65 @@ spec: - A volume is destroyed (or, for remote storage, detached) when the pod is destroyed +--- + +## Other uses of init containers + +- Load content, data sets... + +- Generate configuration (or certificates) + +- Database migrations + +- Wait for other services to be up + + (to avoid flurry of connection errors in main container) + +- etc. + +--- + +## Init containers vs sidecars + +- Init containers run *before* the main container(s) + +- Sidecars run *in parallel* to the main container(s) + +- What's the difference between a sidecar and a "main container"? + +-- + + - sidecar might need to start *before* the main container(s) +
(e.g. if it provides "ambassador"-style connectivity service) + + - sidecar might need to stop *after* the main container(s) +
(ditto) + + - sidecar might need to be stopped automatically when main container(s) complete +
(e.g. for batch jobs) + +- Kubernetes has special support for sidecars! + +--- + +## Sidecars + +- Introduced as an alpha feature in K8S 1.28; GA in K8S 1.33 + +- A sidecar is an `initContainer` with a `restartPolicy: Always` + +- Sidecars are started in the order defined by the `initContainers` list + +- They can have healthchecks + +- Kubernetes doesn't wait for them to complete + + (they run asynchronously) + +- When all the main containers have completed, sidecars are shutdown automatically + + (they don't prevent jobs from completing!) + ??? :EN:- Sharing data between containers with volumes