Lesson 3 of 9 · 21m
Injection, Lifecycle, and the First Broken Deployment
Control how proxies join pods, predict startup and shutdown races, and debug the un-injected workload before blaming routing.
The first mesh incident many teams meet is embarrassingly simple: one pod has no proxy. A deployment was missed by injection, a namespace label changed, a job bypassed admission, or the proxy failed before the application accepted traffic. Because most traffic still works, the exception becomes a confusing security and telemetry hole.
Injection is admission control plus packaging
With Istio sidecar injection, a namespace label enrolls pods:
kubectl label namespace payments istio-injection=enabled --overwrite
kubectl get pods -n payments -o jsonpath='{range .items[*]}{.metadata.name}{" containers="}{.spec.containers[*].name}{"
"}{end}'A workload should show both the application container and istio-proxy. In ambient mode you will not see a sidecar; look instead for namespace labels such as istio.io/dataplane-mode=ambient and node-level ztunnel state. Know which data plane you run before using evidence as proof.
Startup ordering is not decorative
An application can bind and accept connections before its proxy is ready. Istio commonly uses a holdApplicationUntilProxyStarts proxy flag or ordering controls to reduce that race, but jobs, init containers, and custom health gates still need review:
metadata:
annotations:
proxy.istio.io/config: |
{"holdApplicationUntilProxyStarts": true}If batch jobs need direct egress before the proxy is ready, do not solve it by disabling injection globally. Make a narrow, documented exception and put network policy around it.
Shutdown is where connections go to die
During termination Kubernetes sends SIGTERM, endpoints are removed, and proxies drain. The application, sidecar, and kubelet do not magically coordinate perfectly. Long-lived connections, pre-stop hooks, and graceful shutdown behavior matter:
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 12"]The point is not that sleep 12 is universally correct. The point is that a workload must stop accepting new work and finish in-flight work before its proxy disappears.
Debug enrollment before debugging policy
Useful first commands:
kubectl describe pod -n payments payments-api-6c9d77d4c8-x2vkm | sed -n '/Events/,$p'
istioctl analyze -n payments
istioctl proxy-statusproxy-status showing STALE or missing configuration means the data plane does not agree with the control plane. Routing tests made in that state are noise.
Field notes
- CronJobs and Jobs are frequent injection blind spots; verify them separately from long-running deployments.
- A container named
istio-proxydoes not prove a healthy proxy. Check readiness and config synchronization. - Annotation-based exceptions spread quickly. Treat every bypass as technical debt with an owner and expiry.
- Readiness probes that pass before proxy readiness can publish endpoints that immediately reset connections.
Was this lesson helpful?