Skip to main content
Course/Advanced/Service Mesh with Istio
7/890 min
Advanced

Service Mesh with Istio

Add mutual TLS, traffic management, and deep observability to service-to-service communication without changing application code.

advanced90 minRead β†’ Lab β†’ Quiz β†’ Practice
🧠 Brain Warm-Up
🧠 Brain Warm-Up: If you want every service-to-service HTTP call inside your cluster to be encrypted and authenticated β€” but you don't want to add TLS code to 50 microservices β€” how would you enforce that transparently? Who would terminate the TLS, and where would the encryption keys live?

The Problem: Distributed Systems Complexity

As a system grows from a monolith to microservices, new problems emerge:

  • Security: How do you ensure every service-to-service call is encrypted and authenticated?
  • Reliability: How do you add retries, circuit breakers, and timeouts without rewriting every service?
  • Observability: How do you get request traces across 20 services without adding tracing SDK to each?

A service mesh solves all three by moving this logic out of the application into the network layer.

How a Service Mesh Works: The Sidecar Pattern

Istio injects an Envoy proxy sidecar into every Pod (automatically via MutatingAdmissionWebhook). The sidecar intercepts ALL inbound and outbound traffic using iptables rules β€” the application process is unaware.

WITHOUT ISTIO                     WITH ISTIO
─────────────────────             ──────────────────────────────────
Pod A (app container)             Pod A
  β”‚ plain HTTP                      β”‚ app container
  β–Ό                                 β”‚ envoy sidecar ← intercepts traffic
Pod B (app container)               β”‚   (mTLS, retries, metrics)
                                    β–Ό
                                  Pod B
                                    β”‚ envoy sidecar ← mutual TLS
                                    β”‚ app container

Core Istio Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  CONTROL PLANE                        β”‚
β”‚                                                       β”‚
β”‚  istiod (Pilot + Citadel + Galley merged)            β”‚
β”‚  β”œβ”€β”€ Pilot: distributes routing config to sidecars   β”‚
β”‚  β”œβ”€β”€ Citadel: Certificate Authority (issues mTLS certs) β”‚
β”‚  └── Galley: validates Istio config resources        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ xDS API (gRPC streaming)
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     DATA PLANE (every pod)                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚  β”‚ Pod                                  β”‚                       β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚                       β”‚
β”‚  β”‚  β”‚ App       │←───│ Envoy Sidecar β”‚  β”‚                       β”‚
β”‚  β”‚  β”‚ Container │───→│ (istio-proxy) β”‚  β”‚                       β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚                       β”‚
β”‚  β”‚                   Handles:           β”‚                       β”‚
β”‚  β”‚                   β€’ mTLS termination β”‚                       β”‚
β”‚  β”‚                   β€’ retries/timeouts β”‚                       β”‚
β”‚  β”‚                   β€’ metrics/traces   β”‚                       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Mutual TLS (mTLS)

Istio's Citadel component acts as a Certificate Authority. It issues short-lived X.509 certificates to every sidecar based on the Pod's ServiceAccount (SPIFFE identity: spiffe://cluster.local/ns/default/sa/web-sa).

  • Strict mode β€” sidecars only accept mTLS connections; plain HTTP is rejected
  • Permissive mode β€” sidecars accept both mTLS and plain HTTP (migration mode)
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: production
spec:
  mtls:
    mode: STRICT  # Reject all non-mTLS connections in this namespace

Traffic Management

Istio's VirtualService and DestinationRule resources control how traffic is routed between services β€” independently of Kubernetes Services:

# Canary deploy: send 10% of traffic to v2
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: web
spec:
  hosts: [web]
  http:
  - route:
    - destination:
        host: web
        subset: v1
      weight: 90
    - destination:
        host: web
        subset: v2
      weight: 10

Observability: The Golden Signals

Because all traffic passes through Envoy sidecars, Istio automatically collects:

  • Metrics β€” request rate, error rate, latency (exported to Prometheus)
  • Traces β€” distributed traces across all hops (via Jaeger/Zipkin via B3/W3C headers)
  • Access logs β€” every request/response with full metadata

This observability is zero-code β€” no SDK changes required in any application.