Skip to content
StackDecode
IntermediateLesson 20 of 35

Init containers and sidecars

Helpers that run before, or next to, your main container.

Init containers run to completion, in order, before the app starts: wait for a dependency, run a migration, fetch config.

yaml
initContainers:
  - name: wait-db
    image: busybox:1.36
    command: ['sh', '-c', 'until nc -z db 5432; do sleep 2; done']

Sidecars run alongside the main container: log forwarders, proxies, certificate refreshers. Recent Kubernetes versions support native sidecars (an init container with restartPolicy: Always).