Kubernetes Native Sidecar Containers Explained

Updated on
9 min read

Kubernetes native sidecar containers solve a small but consequential lifecycle problem: an application often needs a helper process to start first and stop last. Platform engineers and developers can use them for proxies, log agents, and other supporting processes that belong beside an application in the same Pod. This guide explains how Kubernetes represents these helpers, what ordering it provides, and how to test a manifest safely.

What Are Kubernetes Native Sidecar Containers?

A Kubernetes native sidecar is a long-running container declared in a Pod’s initContainers list with restartPolicy: Always. It starts during Pod initialization, remains running while the application containers run, and is shut down after those application containers. Unlike a regular init container, it is not expected to finish before the Pod starts serving work.

The Kubernetes documentation for sidecar containers defines this behavior and its lifecycle rules. The Kubernetes project calls the surrounding scheduling unit a Pod: its containers share a network namespace and can share mounted volumes, but each container still has its own filesystem and process. Native sidecar support makes startup and shutdown behavior part of the Pod API rather than relying on shell scripts or application-specific coordination.

Why Native Sidecars Exist

Applications frequently depend on helper processes for traffic routing, certificate refresh, telemetry collection, or local log forwarding. Before native sidecars, teams commonly placed a helper in the ordinary containers list. Kubernetes could run it alongside the application, but it did not know that the helper should start before the app or remain alive until the app had exited.

That gap creates practical problems. A short-lived Job can finish its main task while a conventional proxy or telemetry container keeps running, leaving the Job stuck in a non-completed state. During Pod deletion, an app may exit while its proxy is terminated at the same time, cutting off a final request or cleanup operation. A regular init container has the opposite limitation: it runs before app containers, but must finish, so it cannot act as a persistent companion.

Native sidecars express both requirements: run the helper during initialization and keep it alive in the background. The Kubernetes enhancement proposal, KEP-753, documents the API design and the lifecycle cases it addresses.

How Native Sidecars Work

The distinguishing field is restartPolicy: Always on an entry under spec.initContainers. Kubernetes treats that restartable init container as a sidecar. The field belongs on that container; the Pod’s own restart policy does not turn an ordinary init container into a sidecar.

Kubelet processes the init-container list in order. When it reaches a restartable sidecar, the sidecar is started and allowed to keep running while kubelet moves on to the next init container. Regular init containers still need to complete successfully before the next init container can run and before application containers start. If a sidecar defines a startupProbe, kubelet waits for that probe to succeed before proceeding. A readinessProbe can also influence whether the Pod is considered ready to receive traffic.

On Pod termination, Kubernetes first allows the main application containers to stop. It then terminates sidecars in reverse order from how they were listed. This is useful when one helper depends on another: a proxy or log collector can remain available while the application exits, and a downstream helper can be stopped after a helper that depends on it. These steps still share the Pod’s termination grace period. If containers do not exit before the grace period expires, Kubernetes can force termination.

Behavior Regular init container Ordinary app container used as a sidecar Native sidecar
Manifest location initContainers containers initContainers
How it stays running Must exit before startup continues Runs alongside the application restartPolicy: Always keeps it running
Startup relationship Completes before later init and app containers No guaranteed start-before-app ordering Starts during initialization before app containers
Pod shutdown Already completed Stops with other app containers Stops after main containers, in reverse sidecar order
Job completion Does not hold the Job open after it exits Can keep a completed Job running Can stop after the main Job containers finish

This is an API-level lifecycle feature, not an additional scheduling unit. The init-container documentation explains how restartable init containers fit into the existing initialization sequence. Kubernetes still schedules the entire Pod on one node, and its containers share the Pod’s network identity. They can use a shared volume for files, but they do not share a container filesystem automatically.

Components and Key Concepts

  • Restartable init container: An entry in initContainers with restartPolicy: Always. It is the API representation that marks a native sidecar.
  • Regular init container: A setup step that runs to completion. It can appear before or after a sidecar in the init list, so its position defines whether setup happens before or after that sidecar starts.
  • Startup probe: Optional check for a sidecar that needs time to initialize. Its success can gate the start of later init containers.
  • Readiness probe: Optional check that reports whether the helper can serve its purpose. Readiness affects the Pod’s readiness, not whether the container process exists.
  • Termination grace period: The time Kubernetes gives the Pod’s containers to exit. Sidecar ordering improves coordination but does not provide unlimited shutdown time.
  • Shared Pod resources: Sidecars share the Pod IP and can share explicitly mounted volumes. They also consume CPU and memory that must be included in Pod resource planning.

Real-World Uses

Network proxies can start before an application and remain available until it has stopped. This pattern is useful for service-mesh proxies, local gateways, or other helpers that intercept application traffic. Native sidecar lifecycle does not configure traffic interception by itself; the proxy and cluster networking components still need their own configuration.

Log and telemetry agents can read files from a shared volume or collect data while an application runs. They can flush buffered output after the application exits, then terminate. For production log pipelines, a node-level collector may be a better fit when collecting from every container on a node; a per-Pod sidecar is most useful when the helper needs application-specific context or files.

Jobs and batch workloads benefit when a helper is needed during task execution but should not prevent completion. For example, a Job may use a proxy to reach an internal service, or an exporter to capture task metrics. The helper still needs a reliable termination path and must not keep producing work after the main process finishes.

Native sidecars are not automatically the right choice for every supporting process. A daemon that serves many Pods may belong at node level; a separate service may scale and fail independently. Consider the helper’s security boundaries, resource costs, upgrade cadence, and whether sharing a Pod network or volume is actually required.

Getting Started with a Native Sidecar

The following Pod runs a small application that appends timestamps to a shared log file. A BusyBox sidecar tails that file and writes the lines to its own standard output, which can be retrieved with kubectl logs. Save the manifest as pod-with-sidecar.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: web-with-log-sidecar
spec:
  volumes:
    - name: shared-logs
      emptyDir: {}
  initContainers:
    - name: log-forwarder
      image: busybox:1.36
      restartPolicy: Always
      command: ["sh", "-c", "touch /var/log/app/app.log && tail -f /var/log/app/app.log"]
      volumeMounts:
        - name: shared-logs
          mountPath: /var/log/app
  containers:
    - name: app
      image: busybox:1.36
      command: ["sh", "-c", "while true; do date >> /var/log/app/app.log; sleep 5; done"]
      volumeMounts:
        - name: shared-logs
          mountPath: /var/log/app

Apply it to a cluster that supports native sidecars:

kubectl apply -f pod-with-sidecar.yaml
kubectl get pod web-with-log-sidecar
kubectl logs web-with-log-sidecar -c log-forwarder
kubectl describe pod web-with-log-sidecar

The log-forwarder is declared as an init container, but it does not block the application from starting because it is restartable. To observe shutdown ordering, delete the Pod and watch its status:

kubectl delete pod web-with-log-sidecar
kubectl get pod web-with-log-sidecar --watch

Native sidecars are stable in Kubernetes 1.33; earlier clusters may require the SidecarContainers feature gate, which has been enabled by default since 1.29. Check the official feature documentation for the version and feature-gate behavior of the cluster you operate.

If the Pod remains in initialization, inspect events with kubectl describe pod and check image-pull errors or a failing regular init container. If the sidecar starts but the Pod never becomes Ready, check its readiness probe and the application container’s readiness conditions. Use kubectl logs web-with-log-sidecar -c log-forwarder --previous to inspect a terminated sidecar instance. On shutdown, verify that the app exits within the Pod grace period; sidecar ordering cannot preserve the helper beyond that deadline.

Common Misconceptions

“A native sidecar is just another container in the Pod.” It is a container, but its location in initContainers and restart policy give it different startup and termination behavior from an ordinary app container.

“A sidecar can never block Pod readiness.” A readiness probe on the sidecar can affect Pod readiness. A helper that is running but not ready may cause a Pod to remain out of service, depending on its probe and how traffic is managed.

“Native sidecars remove the need to coordinate shutdown.” Kubernetes orders container termination, but the app and helper still need compatible signal handling, timeouts, and a sufficient grace period. A process that ignores termination can still be force-killed.

Changelog

  • Initial publication; checked against Kubernetes sidecar documentation and KEP-753.
  • Last updated: 2026-10-06
TBO Editorial

About the Author

TBO Editorial writes about the latest updates about products and services related to Technology, Business, Finance & Lifestyle. Do get in touch if you want to share any useful article with our community.