Kubernetes native sidecar containers: when teams need them
Native sidecar containers are helper containers that Kubernetes starts before the application containers, keeps running alongside them, and stops after they have exited. Since Kubernetes v1.33 this behavior is stable. You create one by declaring an init container with restartPolicy: Always, which tells the kubelet to treat it as a long-running sidecar rather than a one-time setup step. Teams reach for this pattern when a helper must be ready before the application starts and must keep running until the application stops, for example a log shipper that has to be collecting before the first line is written, a proxy that the application's outbound calls depend on, or a secret agent that must have fetched credentials before the app reads them.
These three workloads share the same failure mode when run as ordinary containers in the same Pod. Kubernetes starts all regular containers at roughly the same time, so the application can begin before the proxy listens or the secret agent has written its file, and nothing in the spec expresses that dependency. Shutdown has the reverse problem: the sidecar may be killed while the application is still flushing its last logs or making final requests, which loses data or produces errors during deploys. Native sidecars give the platform team a declared startup order and a declared shutdown order, so the helper is ready first and stops last. Before adopting the pattern, confirm which cluster versions your platform runs, and check that your chosen distribution and its admission and policy tooling accept init containers with this field set.
How a native sidecar fits into the Pod lifecycle
Startup begins with regular init containers, which must each run to completion. The native sidecar, declared as an init container with restartPolicy: Always, starts next and keeps running, so the main containers start alongside it. A secret agent sidecar that writes into a shared volume crosses a trust boundary, so check what it can write and who can read that volume. At shutdown, the main containers stop first and the sidecar stops after them, which is why a log shipper can flush the final lines.
Startup and shutdown order for a native sidecar inside one Pod.
How Kubernetes orders startup and shutdown for sidecars
A native sidecar is an init container with restartPolicy: Always, and the kubelet handles it differently from a regular init container. Init containers run one after another, and a native sidecar is started in that same init sequence. The important difference is that the kubelet treats the sidecar as started once it is running, so the next init container and then the main containers can begin. The sidecar does not have to exit before the pod moves on, which is what separates it from a classic init container that must complete first.
Once the main containers are running, the sidecar keeps running alongside them. That is the behavior a log shipper, proxy or secret agent depends on: it should be up before the application makes its first call and still be up while the application works. On shutdown, the documented intent is that the sidecar is stopped after the main containers, so it can keep forwarding logs, serving traffic or refreshing credentials while the application drains. Confirm this with the sidecar documentation for your Kubernetes version, and check the terminationGracePeriodSeconds value and any preStop hooks, because they set how long the shutdown sequence has to complete.
Do not assume the ordering from this summary. Build a small test pod with a sidecar that logs timestamps at startup and on SIGTERM, plus a main container that logs when it starts and stops, then record the sequence on the cluster versions you run. Repeat the test after each minor upgrade, and include a case where the sidecar crashes so you know how the kubelet restarts it. Decisions about proxy readiness and log flushing should rest on that observed behavior, and the sidecar containers documentation is the reference to check your findings against.
Which helper pattern fits each workload
This table compares native sidecars with ordinary extra containers, run-once init containers and shared-process or pre-stop workarounds for helper workloads. Read each row as a workload type, then check the startup guarantee and the trade-off your platform team would own. The main takeaway is that native sidecars give ordered startup for long-running helpers, while the other patterns fit tasks that either finish or need no ordering.
| Pattern | When it fits | Startup and shutdown guarantee | Main trade-off for the platform team |
|---|---|---|---|
| Native sidecar (init container with restartPolicy Always) | Log shippers, service proxies and secret agents that the main container needs from the first moment | Starts before main containers and keeps running alongside them; stopped after main containers exit | Requires Kubernetes v1.33 or newer, since native sidecars are stable from that release; admission and policy tooling must accept init containers that keep running |
| Ordinary extra container | Helpers that can start in parallel with the app and tolerate brief startup races | No ordering between containers; the app may start before the helper is ready | Teams must add retry logic or readiness workarounds, and shutdown order is not guaranteed so logs can be lost on termination |
| Run-once init container | Setup tasks such as schema checks, config rendering or one-time secret fetches | Runs to completion before any main container starts; does not run during the pod lifetime | Cannot refresh secrets or ship logs during the pod, so token rotation or continuous shipping needs another mechanism |
| Shared-process or pre-stop workaround | Legacy images that cannot be changed, or helpers wrapped in a script that sleeps before the app exits | Ordering depends on custom scripts and timing rather than a documented Kubernetes guarantee | Brittle under load and across image updates; each team maintains its own scripts and may still drop traffic or logs on shutdown |
| Native sidecar in a Job | Batch pods where a helper such as a log shipper must run only while the main task runs | The Job is considered complete when the main containers finish, and the sidecar is then stopped | Teams must test that the helper flushes its data before the pod is terminated, and confirm the version of Kubernetes they run |
Where Jobs and proxies go wrong with sidecars
Native sidecars fix several old problems, but they introduce their own failure modes around Jobs, startup order, restarts, resource accounting and probes. Each card below names a symptom, the usual cause and the specific settings to check in your manifests before the workload reaches production.
Job never completes
Symptom: a Job's pods stay in Running after the main container has exited, so the Job never reaches Complete. Cause: a sidecar declared as an init container with restartPolicy Always is designed to keep running, and it does not stop just because the main container finished. Check: confirm which container is the Job's work and whether the helper needs an explicit shutdown signal or a termination path that your log shipper or proxy honors.
- Native sidecars stable
- v1.33
Main container starts before the proxy is ready
Symptom: the application fails on its first outbound calls, or secret reads fail, only on some pod starts. Cause: a regular container can start before a proxy or secret agent has finished initializing, because ordering between ordinary containers is not guaranteed. Check: move the proxy or secret agent into the init container list with restartPolicy Always so it starts before the main containers, then confirm its readiness behavior in your own environment.
Sidecar exits early and restarts
Symptom: a log shipper or proxy restarts repeatedly, and the pod shows restart counts on a helper container you did not expect to fail. Cause: the helper crashes on missing configuration, a missing mounted secret or an unreachable backend, and the restart policy brings it back. Check: read the previous container logs for the sidecar, verify the ConfigMap and Secret mounts it depends on, and confirm the backend address is reachable from the pod network.
Helper resource requests inflate scheduling
Symptom: pods stay Pending or nodes look full even though the main application uses little CPU and memory. Cause: requests on native sidecars count toward the pod's total resource requirements, so a generous proxy or agent reserves capacity on every replica. Check: list requests and limits for each sidecar separately, compare them with observed usage, and size the helper for its real throughput rather than copying defaults from another chart.
Health checks target the wrong container
Symptom: the pod reports Ready while the application is failing, or a probe restarts a healthy container because it points at a proxy port. Cause: a probe is attached to the container that owns the port in the manifest, and a sidecar's status endpoint is not the application's health signal. Check: map each probe to the container that serves the endpoint, decide whether a sidecar probe should gate the pod, and test failure paths in a staging namespace before rollout.
Older workarounds left in place
Symptom: manifests carry sleep loops, preStop hacks or wrapper scripts that exist only to order containers. Cause: teams wrote these before native sidecars, and they now conflict with the built-in lifecycle, sometimes delaying shutdown or masking real errors. Check: inventory these scripts in your charts, remove them one workload at a time, and rerun Job completion and shutdown tests after each change.
Converting an existing sidecar to a native sidecar
This sequence moves a helper container such as a log shipper, proxy or secret agent from the main containers list into a native sidecar, and confirms that startup order, shutdown and Job completion behave as intended before the change reaches production. The output is a tested manifest pattern for your workload and a rollback path if something breaks.
Inventory helper containers and their dependencies
List every container in each Pod that does not serve the main workload, including log shippers, proxies, secret agents and service mesh helpers. For each one, record the image, the volumes it mounts, the ports and probes it uses, the environment it reads, and which main containers depend on it being ready. Owners are the application team and the platform team together, since the platform team usually owns the shared helpers. The step is done when you have a written table with one row per helper and a named owner for each, and when you can state which main container fails if that helper is absent.
Confirm the cluster supports native sidecars
Run kubectl version against the target cluster and confirm the server version is v1.33 or newer, since native sidecar containers are stable from that release. Check the version of every kubelet as well, because a node running an older kubelet will not honor the restartPolicy field on an init container. Review the Kubernetes sidecar containers documentation for the behavior you are relying on. The check is done when the server and all node versions are recorded, and any cluster below v1.33 has been placed on a separate track, since this conversion will not work there.
Move each helper into initContainers with restartPolicy Always
In a copy of the manifest for a non-production namespace, remove the helper from the containers list and add it to the initContainers list with restartPolicy set to Always. Keep its image, command, environment and volume mounts unchanged in this first pass so that any later failure can be traced to the move itself. Do not change the main containers in the same commit. The step is done when kubectl apply accepts the manifest and kubectl get pod shows the helper listed under initContainers with a running state once the Pod starts.
Adjust volumes, probes and resource settings
Review shared volumes so that the helper and the main containers mount the same emptyDir or ConfigMap paths they used before, and confirm that no file written by the helper is read before the helper is ready. Replace any probe or readiness logic that relied on the old container order with a probe on the sidecar itself, and check that the Pod's resource requests still cover all running containers. The step is done when a Pod in the test namespace reaches Ready and kubectl describe pod shows the sidecar with its probe results and no unexpected restarts.
Verify startup order
Start the Pod and watch the container status timestamps to confirm that the sidecar starts before the main containers and reports ready before the application begins work. If the application needs the proxy or secret agent at boot, test that it fails safely when the sidecar is delayed by temporarily blocking its dependency. The check is done when kubectl get pod -o yaml shows the sidecar state as running before each main container starts, and the application logs show its first outbound call succeeding through the helper.
Verify Job completion while sidecars run
For Jobs, deploy a test Job that uses a native sidecar and confirm that the Job reaches Complete when the main container exits, even though the sidecar keeps running. Compare this with the older pattern, where the helper kept the Pod alive and needed a separate termination signal. Check that the Job's pods move to a completed state and do not stay in Running indefinitely. The check is done when kubectl get job shows the Job as complete and the Pod shows the main container terminated with exit code zero while the sidecar is torn down by Kubernetes.
Verify shutdown and roll back if needed
Delete the test Pod and confirm the log shipper flushes its buffer and the proxy drains connections before the Pod terminates, by reviewing the helper's logs and the destination system. Keep the previous manifest in version control so that rollback is a single apply. The step is done when the flushed log lines or drained requests appear in the destination, and when the rollback manifest has been applied once in the test namespace and the Pod returned to its previous behavior. Only after both checks pass should the conversion be scheduled for production, using a separate change record.
Replacing older sidecar workarounds
Before native sidecars, teams often ran a log shipper, proxy or secret agent as a second entry in the containers list and relied on startup scripts, retry loops or readiness probes to make the application wait for it. Kubernetes had no notion that the helper was supporting the main container, so the helper could start late, exit first or be stopped during a rolling update while the application still needed it. Native sidecars change this by declaring the helper as an init container with restartPolicy: Always, so kubelet starts it before the main containers and keeps it running alongside them. Check the following when you migrate:
- Startup order: Confirm the application no longer needs a wait script for the helper, and remove the script only after a cold start has been tested.
- Shutdown order: Verify that the helper stops after the main containers during pod termination, so buffered logs or in-flight proxy traffic can drain.
- Probes: Review readiness and liveness probes on the helper, since native sidecars are checked the same way as other containers.
- Resource accounting: Recheck requests and limits, because the helper now runs as part of the init phase.
Confirm the removal of old wait scripts against your own rollout plan, and keep the previous manifest available until the new version passes your tests.
A common workaround for Jobs is to run a proxy or sidecar next to the main task and stop it when the task finishes. Teams did this by sending signals through a shared process namespace, by writing a marker file that the helper polls, or by adding a sleep loop so the Job pod did not finish before the main container. These approaches were fragile: a missed signal left the Job running, and a sleep loop wasted time and resources. With native sidecars, the helper is an init container with restartPolicy: Always, and Kubernetes is designed to stop it once the main containers complete, so the Job can reach completion without custom signaling. Retest the following:
- Completion: Run each Job type and confirm the pod reaches the Completed state after the main container exits.
- Failure paths: Test a main container that fails, and confirm the Job's retry and backoff behavior still matches your expectations.
- Exit codes: Check that monitoring and workflow tools read the same status as before.
- Signal handlers: Remove shared-process signal code only after you confirm nothing else depends on it.
Remove sleep loops and marker files only after these runs pass in a staging environment that matches production.
Teams often used a chain of ordinary init containers to force an order, such as waiting for a database, then a proxy, then a secret agent, with each step checking a port or writing a file. This made the helpers available before the application started, but it did not keep them running afterward, so a proxy started in an early init container could not serve the main container once its init step completed. The chain also grew slow and hard to read as steps were added. Native sidecars let you keep the helper running for the pod's lifetime while the ordinary init containers still run to completion first. Before you remove a chain, check:
- Step purpose: Separate one-time setup steps, which should stay as regular init containers, from helpers that must keep running.
- Dependencies: Map which steps depend on each other, and confirm the native sidecar starts in the position you intend.
- Restart behavior: Test what happens when a helper crashes, since native sidecars restart under the pod's restart policy.
- Timing: Measure startup time before and after, so a slow dependency is not hidden by the new ordering.
The removal of chain scripts should follow your own rollout plan, with a rollback path kept until each service has run cleanly in production.
Securing secret agents and log shippers in production
Treat a sidecar that handles secrets or logs as a privileged component, not as a helper. A secret agent or log shipper usually needs read access to something sensitive, so its service account should be dedicated to that sidecar, bound to a narrow Role, and limited to the specific Secrets or ConfigMaps it needs. Restrict who can get, list and watch Secrets in the namespace, because listing Secrets exposes their values to anyone holding those verbs. This matters more than usual because Kubernetes stores Secrets unencrypted in etcd by default. Confirm with your platform team that encryption at rest is configured for Secrets in your cluster, and that etcd backups are encrypted, since a backup copy otherwise carries the same exposure.
Logs and shared volumes are the quieter leak path. A log shipper that tails an application's files or stdout will forward whatever the application prints, including tokens, personal data or request bodies, so review application logging before the shipper is wired in and decide what gets redacted at the collector. An emptyDir volume shared between a secret agent and the main container is readable by every container that mounts it, so mount it read-only where possible, avoid writing secret material to it, and do not mount node paths that other workloads can read. For external stores, the Kubernetes Secrets good practices documentation names the Secrets Store CSI Driver as one option. Ask your team to confirm how it fits your provider, and whether secret material still lands in a Kubernetes Secret object.
Sidecar images deserve the same review as main images. Pin them by digest, scan them, and record who approved each version, because a proxy or agent runs in every pod that uses it and often holds more privilege than the application. Enforce the Pod Security Standards per namespace through the built-in Pod Security Admission controller, usually at the baseline level as a minimum and restricted where the sidecar can run without extra privileges. Test that the sidecar still starts under restricted before you enforce it, since a shipper that needs root or host paths will be blocked at admission time, not at runtime.
Limits to confirm on your cluster
Native sidecars change how Kubernetes orders and stops containers, so a few behaviors depend on your exact Kubernetes version, distribution and tooling. The cards below list the items to confirm on a test cluster before you move log shippers, proxies or secret agents into sidecar form.
Kubernetes minor version and feature state
Native sidecars are stable since Kubernetes v1.33, so a cluster on an earlier minor version cannot rely on the behavior described here. Confirm the server version with kubectl version and check whether your distribution ships the feature enabled, since some older distributions exposed it behind a feature gate. Your distribution's release notes and documentation are the place to confirm this, not a version number assumed from the upstream release.
Proxy and log shipper shutdown behavior
Native sidecars stop after the main containers exit, but a sidecar only shuts down cleanly if its process handles SIGTERM and flushes buffers. Test whether your log shipper drains its queue and whether your proxy finishes in-flight connections within the pod's termination grace period. Confirm both on a test cluster by sending a termination signal and checking what is delivered before the process exits.
Pod Security Admission for the namespace
Pod Security Admission enforces one of three standards (Privileged, Baseline or Restricted) per namespace, and sidecar images that need root, host paths or extra capabilities can fail admission at creation time. Check the namespace labels with kubectl get namespace --show-labels and dry-run the pod spec with kubectl apply --dry-run=server before rollout. Adjust the sidecar image or the enforcement level deliberately rather than relaxing the namespace by default.
Version skew during control plane upgrades
The version skew policy requires kube-apiserver to be upgraded one minor version at a time and allows kubelets to lag the API server by up to three minor versions. Sidecar behavior depends on the kubelet, so a node pool that lags the control plane can run pods with different sidecar semantics than the new nodes. Plan node upgrades so the kubelet version that runs your sidecar pods is one you have tested.
Version skew policyMonitoring that counts sidecar resources
Dashboards that sum container metrics per pod may double count or miss sidecar resource use, depending on how they filter init containers and labels. Check whether your kube-state-metrics and cAdvisor queries include the sidecar containers, and whether CPU and memory requests for sidecars are included in capacity planning. Verify this by comparing a pod's reported totals with the sum of its individual container metrics on a test workload.
Questions teams ask before adopting native sidecars
What does adopting native sidecars cost and what drives the effort?
Most of the cost is engineering time, not software, because native sidecars are a built-in Kubernetes feature stable since v1.33. The effort scales with how many workloads run helpers such as log shippers, proxies and secret agents, how many of those helpers have startup or shutdown dependencies, and how many Jobs need to finish while a helper keeps running. A quote should itemize the workloads in scope, the number of helpers per workload, the test environments needed and the change process for each owning team. Confirm with your own team whether the cluster already runs v1.33 or later, since that decides whether the work is a configuration change or an upgrade first.
How long does a sidecar migration take?
Duration depends on the count of pods that carry sidecar workarounds, the number of distinct owning teams and how many Jobs must change behavior. A single application with one log shipper is a small change, while a platform with dozens of shared helpers across many namespaces needs staged rollouts, canary namespaces and a rollback plan for each. Ask for a schedule that separates inventory, pilot, rollout and cleanup of old workarounds, and confirm the approval steps each team requires. No fixed duration applies to every environment, so treat any single estimate as a starting point until the inventory is complete.
What does the client team need to provide?
The work needs cluster access with rights to read workloads, deploy manifests in staging and production, and view events and logs. It also needs a non-production cluster or namespace where helpers can be tested, a set of representative test workloads, including at least one Job, and a named owner for each helper such as the logging, proxy or secrets team. Those owners decide the expected shutdown order and the acceptable log loss window. Without them, the team cannot verify that a helper starts before the application or drains logs after it exits.
Can an in-house platform team do this without a partner?
Yes, a capable platform team can adopt native sidecars internally, particularly when the number of workloads is small and the team already manages Pod specifications and rollouts. The main risks are not technical complexity but missing inventory, unclear ownership of helpers and insufficient test coverage for Job completion and shutdown behavior. A partner is most useful when many teams share helpers, when deadlines compete with other platform work, or when audit evidence for changes is required. Decide based on your own capacity and the number of owning teams, then confirm the plan in writing either way.
How do native sidecars interact with Kubernetes upgrades?
Native sidecars depend on the cluster version, so the upgrade plan and the sidecar plan need to be sequenced together. Kubernetes releases approximately three times per year, and the project maintains the three most recent minor releases, so clusters on older minors will eventually need upgrades before or after the sidecar change. The version skew policy requires upgrading kube-apiserver one minor version at a time, before the other control plane components and kubelets, so plan the sidecar rollout against the target minor version. Keep a test cluster on the same minor version as production to catch behavior differences before each upgrade.
When should we bring in a partner for sidecar work?
Bring in a partner when the inventory shows many shared helpers, when several teams must agree on shutdown order, or when the change needs documented evidence for an internal review or a compliance assessment. DeployOpen plans, implements and documents this work in infrastructure you control, and prepares the evidence your reviewers request, but it does not issue audit reports or certifications. Request a written scope that names the clusters, namespaces, helpers and Jobs covered, the deliverables and the acceptance tests before work begins.
Do Jobs need changes when a sidecar keeps running?
Yes, Jobs often need review because a helper that keeps running can prevent the Job from reaching completion. Native sidecars are designed so that the main containers of a Job can finish while the sidecar is stopped as part of the pod lifecycle, but each Job should be tested with its real helpers to confirm this in your cluster. Check that log shippers flush before exit, that secret agents do not hold leases past completion, and that retries behave as expected. Record the expected exit behavior for each Job type so that owners can verify it after upgrades.
How DeployOpen works on this
DeployOpen plans, implements, documents and supports self-hosted Kubernetes platforms inside infrastructure you control. For native sidecar containers, that means agreeing which workloads move to the native model, building and testing the pod specs in your own clusters, and leaving your team with written runbooks and a support path.
How we scope
- Inventory every current sidecar, init container and workaround across the namespaces in scope before design starts.
- Classify each sidecar by lifecycle need: log shipper, proxy, secret agent or job helper, with its start and shutdown requirements.
- Record the target Kubernetes minor version and confirm the cluster runs a release where native sidecars are stable.
How we build
- Convert selected sidecars to init containers with restartPolicy Always, keeping probes, resource limits and volume mounts aligned.
- Test start ordering and termination behavior for Jobs and CronJobs where the main container finishes while sidecars keep running.
- Verify application behavior during rolling updates, node drains and forced pod deletion in a staging cluster before production rollout.
How we hand over
- Deliver the manifests, Helm values or Kustomize overlays in a Git repository your team owns and can review.
- Document the sidecar inventory, lifecycle decisions, known limitations and the test cases used for each workload.
- Walk your platform and application engineers through the runbook, including how to roll back to the previous pod layout.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
- Ongoing support, Kubernetes upgrades and continuous testing are available as retainers when your cluster versions change.
- Ask us to confirm which parts of the sidecar design need review at each minor version upgrade in your environment.

