What the sidecar pattern is, the jobs sidecars usually do in Kubernetes, native sidecar containers, the costs in memory, startup ordering and upgrades, and the alternatives: libraries in the process, node agents and sidecar-less meshes.

A sidecar is a second container that runs next to your application in the same pod and adds something the application does not do itself, such as a proxy for mTLS and retries or an agent that ships logs.
It became the default way to bolt platform features onto services without touching their code, and that convenience costs something in every pod, with newer options making the pattern optional for many of its original jobs.
The sidecar pattern description in the Azure Architecture Center frames it as isolation and encapsulation: the helper can be written in another language and maintained by another team, and the app talks to it over localhost or a shared volume.
For years a sidecar was a second entry in containers, which caused two known problems: a Job never completed because the proxy kept running, and the proxy could stop before the app during shutdown and drop in-flight requests. Native sidecar containers, stable since Kubernetes 1.33, fix both by declaring the sidecar as an init container that keeps running:
apiVersion: v1
kind: Pod
metadata:
name: api
spec:
initContainers:
- name: log-shipper
image: fluent/fluent-bit:3.2
restartPolicy: Always # makes it a sidecar: starts first, stops last
volumeMounts:
- { name: logs, mountPath: /var/log/app }
containers:
- name: api
image: example/api:1.4.0
volumeMounts:
- { name: logs, mountPath: /var/log/app }
volumes:
- name: logs
emptyDir: {}
Kubernetes starts the sidecar before the app containers, does not count it when deciding whether a Job finished, and terminates it after the app containers on shutdown.
The costs are multiplied by the number of pods, which is easy to underestimate:
These costs are why meshes moved away from per-pod proxies: Istio's ambient mode handles mTLS in a per-node component and only adds a proxy where layer 7 features are needed.
Best fit: sidecars when the helper must be language-neutral and owned by a platform team; node agents or in-process libraries when the per-pod cost and operational overhead outweigh that.
Encore brings infrastructure from code, and many jobs a sidecar does are handled by its runtime inside the application process: every request is traced across services, a service calls another as a typed function through generated clients described in the API calls docs, and secrets are injected into the container on deploy instead of fetched by an agent. Policy that would otherwise live in proxy config goes in middleware in code:
Run in your terminal to get started locally.
package checkout
import (
"context"
"time"
"encore.app/inventory" // another service in the same app
"encore.dev/middleware"
"encore.dev/rlog"
)
var secrets struct {
PaymentProviderKey string
}
// Applies to every endpoint in this service, as a proxy filter would.
//
//encore:middleware target=all
func Timing(req middleware.Request, next middleware.Next) middleware.Response {
start := time.Now()
resp := next(req)
rlog.Info("handled", "endpoint", req.Data().Endpoint, "duration_ms", time.Since(start).Milliseconds())
return resp
}
type PlaceParams struct {
SKU string `json:"sku"`
Quantity int `json:"quantity"`
}
//encore:api auth method=POST path=/checkout
func Place(ctx context.Context, p *PlaceParams) error {
// A typed call to the inventory service; discovery and tracing are handled by the runtime.
if _, err := inventory.Reserve(ctx, &inventory.ReserveParams{SKU: p.SKU, Quantity: p.Quantity}); err != nil {
return err
}
return charge(ctx, secrets.PaymentProviderKey)
}
func charge(ctx context.Context, apiKey string) error {
// Payment provider call goes here.
return nil
}
encore run runs every service locally with the same tracing, so the call from checkout to inventory appears in one trace on a laptop, and on deploy the services run on ECS, EKS or Cloud Run in your own account, as the AWS infrastructure docs describe, without a proxy container in each task.
An AI coding agent adding a call to another service writes a function call that the compiler checks, rather than a URL plus a proxy route, and the trace shows whether it worked on the first local run.
Best fit: backends that want tracing, service calls and secrets handled without running and upgrading per-pod helpers.
List the sidecars you run and the job each does. Keep the ones that need to be language-neutral and platform-owned, move per-pod log and metrics agents to node agents, and replace proxies with in-process handling where the services are yours to change. Use native sidecar containers for whatever remains.
A sidecar is a helper process deployed next to an application container, sharing its lifecycle, network and often its filesystem, to add a capability such as a proxy, a log shipper or a secrets agent without changing the application code.
They are init containers with restartPolicy: Always. Kubernetes starts them before the app containers, keeps them running for the life of the pod, and stops them after the app containers, which fixes the old problems of Jobs that never finished and proxies that shut down first. The feature is stable since Kubernetes 1.33.
Each pod pays the sidecar's CPU and memory, startup and shutdown need ordering, upgrading the sidecar means restarting every pod, and one more process per pod adds failure modes and configuration to debug.
No. Tracing, metrics, service-to-service calls and secrets are handled by the Encore runtime inside the application process, so a service needs no proxy or agent container for those concerns.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.