Starting a container/pod after running the istio-proxy
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In Istio-enabled Kubernetes clusters, the istio-proxy (Envoy) sidecar starts alongside your application container. If your application tries to make network calls before the sidecar is ready, those calls fail because the iptables rules redirect traffic to the not-yet-ready proxy. The solution depends on your Istio version: Istio 1.7+ supports holdApplicationUntilProxyStarts, Istio 1.18+ uses native sidecar containers (Kubernetes 1.28+), and older versions require init container workarounds.
The Problem
Istio injects iptables rules via the istio-init container that redirect all traffic through the Envoy sidecar. If the sidecar is not listening when your application starts, outbound connections are refused.
Fix 1: holdApplicationUntilProxyStarts (Istio 1.7+)
This setting makes the sidecar injector add a postStart lifecycle hook that blocks the application container from starting until the Envoy proxy is ready to accept traffic.
Fix 2: Native Sidecar Containers (Istio 1.18+ / Kubernetes 1.28+)
Kubernetes 1.28 introduced native sidecar containers (init containers with restartPolicy: Always). Istio 1.18+ uses this feature to guarantee the proxy is running before application containers start.
Fix 3: Init Container Workaround (Older Istio)
This init container polls the Envoy health endpoint (localhost:15021/healthz/ready) before allowing the application container to start. However, this only works if the proxy is started before init containers, which depends on injection order.
Fix 4: Application-Level Retry
Adding retry logic makes your application resilient regardless of sidecar timing. This is a good practice even outside Istio because network calls can fail for many reasons.
Fix 5: Sidecar Injection Order
A postStart hook with a short delay is a simple workaround, but it is fragile — the required delay depends on cluster load and proxy startup time.
Handling Proxy Shutdown (Exit Order)
For Kubernetes Jobs and CronJobs, the istio-proxy keeps the pod running after the application container exits. Use the /quitquitquit endpoint to tell the proxy to shut down.
Common Pitfalls
- Not enabling holdApplicationUntilProxyStarts: Without this setting, application containers and the sidecar start simultaneously. Fast-starting apps that immediately make network calls will fail on the first request.
- Init container cannot reach the proxy: Init containers run before sidecar injection in most configurations. The
wait-for-proxyinit container pattern only works if the proxy is already injected and running, which requires Kubernetes 1.28+ native sidecars. - Jobs stuck in Running due to proxy: Kubernetes Jobs complete when all containers exit. The
istio-proxydoes not exit on its own, leaving the Job in Running state. Usequitquitquitendpoint or setISTIO_QUIT_APItotrue. - Health checks failing during startup: If your readiness probe hits an endpoint that goes through the sidecar, it fails while the proxy is starting. Use direct container ports or
holdApplicationUntilProxyStarts. - Hardcoded sleep as a workaround:
sleep 5in a postStart hook is unreliable. Proxy startup time varies with cluster load. Use the health endpoint poll orholdApplicationUntilProxyStartsfor deterministic behavior.
Summary
- Use
holdApplicationUntilProxyStarts: true(Istio 1.7+) for the simplest fix - Kubernetes 1.28+ with Istio 1.18+ uses native sidecar containers that guarantee startup order
- For older versions, poll
localhost:15021/healthz/readyin an init container or application retry logic - For Jobs and CronJobs, call
localhost:15020/quitquitquitto stop the proxy after the app exits - Add application-level retry logic as defense-in-depth regardless of sidecar configuration
Related reading
- Starting minikube in ec2 shows X Sorry, Kubernetes v1.18.0 requires conntrack to be installed in root''s path
- StatefulSet vs Retain reclaim policy of a PersistentVolume
- StatefulSets vs Deployments for stateless applications on Kubernetes
- Static outgoing IP in Kubernetes
- Starting a Kafka topics using Docker Compose with spotify/kafka?
- Starting a shell in the Docker Alpine container
- Static outgoing IP in Kubernetes
- String operation on env variables on Kubernetes

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.