Sidecar Injection
Sidecar injection is the automatic process by which a service mesh adds its proxy container to new pods. A Kubernetes mutating admission webhook rewrites the pod spec at creation time, so your manifests do not change.
How it works
When a pod creation request reaches the API server, the mesh's webhook intercepts it and adds the proxy container (and an init container or CNI step that sets up traffic redirection). The pod then starts with the app and the sidecar together.
mesh injector"] W -->|"adds proxy container"| A A --> P["Pod starts
app + sidecar"] classDef step fill:#DBEAFE,color:#1E293B classDef hook fill:#EDE9FE,color:#1E293B classDef out fill:#D1FAE5,color:#1E293B class D,A step class W hook class P out
Enable it
kubectl label namespace production istio-injection=enabledkubectl get namespace production --show-labelskubectl rollout restart deployment -n production # existing pods need a restartIstio also supports revision labels (istio.io/rev=<revision>) for canary upgrades of the mesh. Per-pod control uses the sidecar.istio.io/inject label.
Verify
kubectl get pods -n production# orders-api-abc-xyz 2/2 Running# 2/2 means app and sidecar. 1/1 means injection did not happen.Manual injection
istioctl kube-inject -f deployment.yaml | kubectl apply -f -RememberLabeling a namespace only affects new pods. Existing pods keep running without a sidecar until recreated.
Common MistakeEnabling injection in
kube-systemoristio-system. Core components should not have their traffic proxied.
TipInjection is a prerequisite for sidecar-based mTLS, so run PERMISSIVE mTLS while you roll it out.
Frequently Asked Questions
How does a sidecar get added without editing my YAML?
A mutating admission webhook intercepts pod creation and modifies the pod spec before it is persisted. Your Deployment manifest is untouched, and the change happens at the API server.
What is a common gotcha with injection?
Jobs may never complete because the sidecar keeps running, and startup ordering can cause early outbound calls to fail. Native sidecar containers and mesh settings address this.
How do I skip injection for one pod?
Label the pod with sidecar.istio.io/inject set to false.