Skip to main content

Implementing a Service Mesh with Istio and Linkerd

Learn how Istio and Linkerd add mTLS, canary releases, circuit breaking and observability to Kubernetes services without changing app code.

52 Terms

Overview and What You Will Learn

A service mesh is an infrastructure layer of proxies that handles service-to-service traffic in a Kubernetes cluster. It adds mutual TLS, traffic shifting, retries, circuit breaking and request metrics without any change to application code, because the proxies sit next to your workloads and the control plane configures them centrally.

By the end of this lab you will be able to:

  • Explain the data plane and control plane, and the difference between sidecar and ambient modes
  • Enforce mTLS between services and prove it works
  • Run a canary release with exact traffic percentages and roll it back safely
  • Configure retries, timeouts, connection limits and outlier detection
  • Restrict which services can call each other with authorization policies
  • Read live service topology and metrics in Kiali
  • Choose between Istio and Linkerd for your team

Why This Matters in Production

With 40 microservices, one slow dependency can take down the rest. Suppose the payments service slows down, so the orders service waits on it, runs out of threads and also slows down, and every caller of orders then does the same. This chain is called a cascading failure. Plain Kubernetes gives each pod an IP address and each Service a stable name, but it does not retry, encrypt, measure latency per service or stop calling an unhealthy backend. You could write that logic into every service in every language, or you can put it in the mesh once. Teams that handle sensitive internal traffic, such as a trading platform like Zerodha or a payments platform like Razorpay, also use the mesh to meet requirements for encrypted and authenticated service-to-service calls.

Core Principles

A mesh has a data plane and a control plane. The data plane is the proxies that carry every request, and the control plane (istiod in Istio) watches the cluster, computes configuration and pushes it to the proxies. The control plane never sees your request traffic.

flowchart LR subgraph P1[Orders pod] A[Orders app] --> B[Sidecar proxy] end subgraph P2[Payments pod] C[Sidecar proxy] --> D[Payments app] end B -->|mTLS| C E[istiod
control plane] -.->|Config| B E -.->|Config| C classDef app fill:#326CE5,color:#FFFFFF classDef proxy fill:#F97316,color:#FFFFFF classDef control fill:#8B5CF6,color:#FFFFFF class A,D app class B,C proxy class E control

In the classic sidecar mode, the mesh injects a proxy container into every pod. The proxy shares the pod's network namespace and captures traffic with iptables rules, so the app opens a plain connection and the two sidecars set up the encrypted tunnel between them. Istio uses Envoy as its proxy, and Linkerd uses its own lightweight Rust proxy.

Istio also offers ambient mode, which became generally available in Istio 1.24 (November 2024). It removes per-pod sidecars. A node-level ztunnel handles identity, mTLS and L4 policy, and an optional waypoint proxy handles L7 features such as routing and retries for the services that need them.

Sidecar mode Ambient mode (Istio)
Proxy location One proxy per pod ztunnel per node, optional waypoint per service
Enable per namespace istio-injection=enabled label istio.io/dataplane-mode=ambient label
Pods restarted to join Yes No
L7 features Always available Need a waypoint proxy

Istio and Linkerd solve the same core problems with different trade-offs:

Dimension Istio Linkerd
Scope and complexity Largest feature set, many CRDs, steeper learning curve Smaller feature set, simpler mental model
Data plane Envoy sidecars or ambient mode Rust micro-proxy sidecars
Resource use Higher in sidecar mode, lower in ambient Generally lighter in published comparisons (measure your own)
Traffic splitting VirtualService and DestinationRule, or Gateway API Gateway API HTTPRoute
Resilience Retries, timeouts, outlier detection, connection limits, fault injection Retries, timeouts and circuit breaking (confirm which distribution includes it)
Releases Open-source releases from the Istio project Open-source edge releases are free, and stable builds come from Buoyant Enterprise for Linkerd

Two points about Linkerd deserve care. First, since Linkerd 2.15 (February 2024) the open-source project no longer publishes artifacts tagged stable. The source stays Apache 2.0 and weekly edge releases remain free, while stable builds are distributed through Buoyant Enterprise for Linkerd, which has been free for small organisations and trials (check current terms). Second, its feature set around circuit breaking has changed across versions, so check the documentation for the version you plan to run.

Remember

Both Istio and Linkerd are CNCF graduated projects, so maturity is not the deciding factor. The deciding factors are operational complexity, the features you need (fault injection, advanced routing, multi-cluster) and how you want to receive releases.

Detailed Step-by-Step Practical Lab

How to Install Istio on a Local Kubernetes Cluster

Install the CLI, then install the control plane with the demo profile, which includes gateways and generous telemetry settings suited to learning. For production clusters use the default profile (or ambient) and manage the install with Helm or GitOps rather than interactive commands.

Bash
curl -L https://istio.io/downloadIstio | sh -
cd istio-*
export PATH=$PWD/bin:$PATH
istioctl version
# Install with the demo profile (learning only)
istioctl install --set profile=demo -y
# istiod and the gateways should be Running
kubectl get pods -n istio-system

The networking and security APIs used below (networking.istio.io/v1, security.istio.io/v1) need Istio 1.22 or newer. Run istioctl analyze after every change, because it catches many configuration mistakes before they reach traffic.

How to Enable Sidecar Injection and Deploy Two Versions of a Service

Label a namespace and the mesh injects a sidecar into every new pod created in it. Pods that existed before the label need a restart. The example uses http-echo so each version answers with its own name, which makes traffic splitting easy to see.

Bash
kubectl create namespace shop
kubectl label namespace shop istio-injection=enabled
kubectl apply -n shop -f - << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders-v1
spec:
replicas: 2
selector:
matchLabels:
app: orders
version: v1
template:
metadata:
labels:
app: orders
version: v1
spec:
containers:
- name: orders
image: hashicorp/http-echo:1.0
args: ["-text=orders v1"]
ports:
- containerPort: 5678
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 128Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders-v2
spec:
replicas: 2
selector:
matchLabels:
app: orders
version: v2
template:
metadata:
labels:
app: orders
version: v2
spec:
containers:
- name: orders
image: hashicorp/http-echo:1.0
args: ["-text=orders v2"]
ports:
- containerPort: 5678
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
name: orders
spec:
selector:
app: orders
ports:
- name: http
port: 80
targetPort: 5678
EOF
# A client pod inside the mesh to send test traffic
kubectl run client -n shop --image=curlimages/curl:8.10.1 --command -- sleep 36000
kubectl get pods -n shop

Every pod should show 2/2 ready containers, which means the application and the sidecar are both running. If you see 1/1, injection did not happen: check the namespace label and restart the deployment with kubectl rollout restart deployment -n shop.

Tip

Name Service ports with a protocol prefix such as http or grpc. Istio uses the name to choose HTTP behaviour (metrics, routing, retries), and an unnamed port is treated more conservatively.

How to Run a Canary Release with Traffic Splitting

A canary release sends a small share of real traffic to a new version and promotes it only if error rate and latency stay healthy. In Istio, a DestinationRule defines the subsets (which pods are v1 and v2) and a VirtualService assigns the weights. You need both, and the weights do not depend on pod counts.

Bash
kubectl apply -n shop -f - << 'EOF'
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: orders
spec:
host: orders
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: orders
spec:
hosts:
- orders
http:
- route:
- destination:
host: orders
subset: v1
weight: 90
- destination:
host: orders
subset: v2
weight: 10
EOF
# Send 100 requests and count the answers
kubectl exec -n shop client -c client -- sh -c 'for i in $(seq 1 100); do curl -s http://orders; done' | sort | uniq -c

Expect roughly 90 answers from v1 and 10 from v2. To promote, change the weights to 0 and 100 and apply again. To roll back, set v1 to 100 and v2 to 0.

Common Mistake

Rolling back by deleting the VirtualService. Without it, the plain Kubernetes Service spreads traffic across all matching pods, which means roughly half of requests would still hit v2 in this lab. Roll back by setting the weights explicitly.

Header-based routing lets internal testers reach v2 before any real user does:

YAML
http:
- match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: orders
subset: v2
- route:
- destination:
host: orders
subset: v1
How to Enforce and Verify mTLS Between Services

mTLS (mutual TLS) means both sides of a connection prove their identity with certificates, so traffic between services is encrypted and each caller is authenticated. The mesh issues workload certificates automatically and rotates them (Istio's default lifetime is 24 hours). In sidecar mode and ambient mode, mTLS between mesh workloads is on by default in permissive form, and STRICT mode rejects any plain-text traffic.

Bash
kubectl apply -n shop -f - << 'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
spec:
mtls:
mode: STRICT
EOF

Prove it from both sides. A client outside the mesh must now be refused, and a client inside the mesh must still work:

Bash
# Outside the mesh: a namespace without injection (this call should fail)
kubectl create namespace legacy
kubectl run plain -n legacy --image=curlimages/curl:8.10.1 --restart=Never --rm -it -- \
curl -sv --max-time 5 http://orders.shop.svc.cluster.local
# Inside the mesh: still works, and the metric shows the connection was mutual TLS
kubectl exec -n shop client -c client -- curl -s http://orders
POD=$(kubectl get pod -n shop -l app=orders -o jsonpath='{.items[0].metadata.name}')
kubectl exec -n shop "$POD" -c istio-proxy -- \
curl -s localhost:15020/stats/prometheus | grep 'istio_requests_total' | grep mutual_tls | head -3

Look for the label connection_security_policy="mutual_tls" on istio_requests_total. In Kiali, encrypted edges on the service graph show a lock icon.

Security

Switching to STRICT on an existing cluster breaks any workload that has no sidecar yet. Start in PERMISSIVE mode, roll out injection namespace by namespace, confirm the metrics show mutual TLS everywhere, and only then switch to STRICT.

How to Restrict Which Services Can Call Each Other

mTLS proves who is calling, and an authorization policy decides what that caller may do. As soon as one ALLOW policy applies to a workload, any request that does not match an allow rule is denied, so a single policy turns the workload into a closed door with an explicit guest list.

YAML
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: orders-allow-checkout
namespace: shop
spec:
selector:
matchLabels:
app: orders
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/shop/sa/checkout"]
to:
- operation:
methods: ["GET", "POST"]

The principal is the caller's service account identity, so give each service its own Kubernetes service account and never share one account between services. Roll these policies out namespace by namespace and test them, because a missing rule produces 403 or connection errors.

How to Configure Retries, Timeouts and Circuit Breaking

Resilience settings stop one slow or failing backend from taking down its callers. Retries and timeouts live in the VirtualService. Connection limits and outlier detection (which ejects failing endpoints from the load-balancing pool) live in the DestinationRule. A host can have only one DestinationRule, so add trafficPolicy to the existing orders rule rather than creating a second one.

Bash
kubectl apply -n shop -f - << 'EOF'
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: orders
spec:
host: orders
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
http:
http1MaxPendingRequests: 50
http2MaxRequests: 200
maxRequestsPerConnection: 10
outlierDetection:
consecutive5xxErrors: 5
interval: 10s
baseEjectionTime: 30s
maxEjectionPercent: 50
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: orders
spec:
hosts:
- orders
http:
- timeout: 5s
retries:
attempts: 2
perTryTimeout: 2s
retryOn: 5xx,connect-failure
route:
- destination:
host: orders
subset: v1
weight: 100
EOF

What each part does:

  • connectionPool limits queued and concurrent requests, so a slow backend gets overflow rejections (HTTP 503) instead of unlimited queueing
  • outlierDetection ejects an endpoint after 5 consecutive 5xx responses and returns it to the pool after the ejection time, with a cap on how many endpoints may be ejected at once
  • timeout and retries bound how long a caller waits and how many times a failed request is retried

Two behaviours surprise people. First, outlier detection is tracked by each calling proxy separately, so each caller's sidecar decides for itself which endpoints to eject. It is not a single circuit state shared by the whole mesh and it is not the same as application-level breakers such as Resilience4j. Second, retries multiply load. Retry only idempotent operations, keep attempts low and always pair retries with timeouts, or a struggling backend gets even more traffic.

Common Mistake

Setting maxEjectionPercent to 100. If every endpoint is ejected, callers have nowhere to send traffic. Keep it at 50 or lower so part of the pool always stays in rotation.

How to Observe Traffic with Kiali and Prometheus Metrics

Every request passes through a proxy, so the mesh produces latency, error rate and volume metrics for every service pair with no instrumentation in your code. Kiali draws these as a live service graph, and Prometheus stores the underlying metrics.

Bash
# From the istio-* directory: install the sample observability addons
kubectl apply -f samples/addons/prometheus.yaml
kubectl apply -f samples/addons/kiali.yaml
# Generate steady traffic in the background, then open the dashboard
kubectl exec -n shop client -c client -- sh -c 'while true; do curl -s http://orders > /dev/null; sleep 0.2; done' &
istioctl dashboard kiali

In Kiali, open the Graph view for the shop namespace to see which services call which, the share of traffic on v1 and v2, error rates, and lock icons for mTLS. The addons are for evaluation. In production, run your own Prometheus and Grafana and follow the Istio documentation for scraping.

Metric What it measures
istio_requests_total Request count by source, destination, response code and security policy
istio_request_duration_milliseconds Latency histogram per service pair
istio_tcp_connections_opened_total TCP connection rate for non-HTTP traffic
How to Try Istio Ambient Mode

Ambient mode gives you mTLS and L4 policy without injecting sidecars. Install the ambient profile on a clean cluster and label a namespace. Pods keep running without restarts, and ztunnel picks up their traffic.

Bash
istioctl install --set profile=ambient -y
kubectl create namespace ambient-lab
kubectl label namespace ambient-lab istio.io/dataplane-mode=ambient
# One ztunnel pod per node
kubectl get pods -n istio-system -l app=ztunnel
istioctl ztunnel-config workloads

L7 features such as header routing and retries need a waypoint proxy for the namespace or service, which uses the Kubernetes Gateway API. Do not label the same namespace for both sidecar injection and ambient mode.

How to Get Started with Linkerd

Linkerd installs with a CLI that checks the cluster, installs its CRDs and control plane, and then injects its proxy into annotated namespaces. Follow the current getting-started guide for the release you choose, since the open-source path uses edge releases.

Bash
linkerd check --pre
linkerd install --crds | kubectl apply -f -
linkerd install | kubectl apply -f -
linkerd check
# Opt a namespace in, then restart workloads to inject the proxy
kubectl annotate namespace shop linkerd.io/inject=enabled
kubectl rollout restart deployment -n shop

Linkerd enables mTLS automatically between meshed pods. It splits traffic with Gateway API HTTPRoute resources that give weighted backends, which means each version needs its own Service. Check the documentation for your version for the exact API group and fields.

How to Clean Up the Lab
Bash
kubectl delete namespace shop legacy ambient-lab
istioctl uninstall --purge -y
kubectl delete namespace istio-system

Production Best Practices & Common Pitfalls

  • Adopt in stages. Start with observability and PERMISSIVE mTLS, then move to STRICT and authorization policies.
  • Set sidecar resources. A sidecar's memory and CPU use depends on mesh size and traffic, so set requests and limits, and measure real usage before sizing the cluster. In Istio you can set them globally or per pod with annotations such as sidecar.istio.io/proxyCPU.
  • Delay the app until the proxy is ready. If your app calls out at startup, set holdApplicationUntilProxyStarts in the proxy config for that pod, or the first requests can fail.
  • Keep system namespaces out of the mesh. Do not inject kube-system or istio-system.
  • Restart after labelling. Existing pods only get sidecars when they are recreated.
  • Validate every change. Run istioctl analyze and check istioctl proxy-status to confirm proxies are in sync.
  • Version carefully. Check which Kubernetes versions your Istio or Linkerd release supports before you upgrade either one.
Mistake Problem Fix
STRICT mTLS on day one Workloads without sidecars cannot connect Start in PERMISSIVE, then switch
Subset in a VirtualService with no DestinationRule 503 errors for that route Define the subsets, run istioctl analyze
Two DestinationRule resources for one host Settings conflict or are ignored One rule per host, with all policies in it
Rolling back by deleting the VirtualService Traffic falls back to even pod-level balancing Set explicit 100 and 0 weights
Shared service account across services Authorization cannot tell callers apart One service account per workload
Unbounded retries Retry storms against a struggling backend Low attempts, per-try timeouts

Quick Reference & Troubleshooting Commands

Resource or command What it does
PeerAuthentication Sets mTLS mode (STRICT or PERMISSIVE) per namespace or workload
VirtualService Routing rules: weights, header matches, retries, timeouts
DestinationRule Subsets, load balancing, connection pool and outlier detection
AuthorizationPolicy Which identities may call which workloads
istioctl analyze -n shop Checks configuration for errors
istioctl proxy-status Shows whether each proxy is in sync with the control plane
istioctl proxy-config routes POD -n shop Shows the routes a proxy actually received
istioctl dashboard kiali Opens the Kiali service graph
Symptom First check What to look for
Pod shows 1/1 instead of 2/2 Namespace label and pod age Label missing, or pod created before the label
503 after applying a route istioctl analyze Missing subset, host name mismatch
Calls fail after STRICT Client namespace Caller has no sidecar, or is outside the mesh
403 from a service AuthorizationPolicy list Caller identity not in an allow rule
Config not taking effect istioctl proxy-status Proxy shown as stale or not synced

Interview Questions This Topic Maps To

  • How does a service mesh provide mTLS without application code changes, and what happens on the network when one service calls another?
  • How would you canary 5% of traffic to a new payments version with an instant rollback path, and why is deleting the routing resource a poor rollback?
  • Compare Istio's outlier detection with an application-level circuit breaker. Where can it fail to protect a caller?
  • What would you check before turning on STRICT mTLS in a cluster with 200 pods, and what is the risk of skipping that check?
  • When would you choose Istio ambient mode over sidecars, and what do you lose without a waypoint proxy?

Resources

Velero vs etcd Snapshot: Which Do You Need?

Velero vs etcd Snapshot: Which Do You Need?

Velero and etcd snapshots protect different layers of a Kubernetes cluster. See what each backs up, what each misses, and why most DR needs both.

11 min read•Aug 2026
Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient cuts the sidecar tax at L4, but L7 adds waypoint hops, and Linkerd stable builds now come from Buoyant. Choose with tests.

11 min read•Aug 2026
Nginx Ingress vs Traefik vs Gateway API in 2026

Nginx Ingress vs Traefik vs Gateway API in 2026

Ingress-NGINX is retired. Compare Traefik and Gateway API controllers as replacements, plus a safe migration plan that avoids outages.

10 min read•Aug 2026
OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno compared for 2026: Rego vs YAML, mutation, reporting, and operations, plus how to pick a Kubernetes policy engine.

10 min read•Aug 2026
Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize compared for 2026 - templating vs patching, Helm 4's new features, and why most production teams end up running both.

5 min read•Aug 2026
Prometheus vs Datadog vs New Relic: Real Costs

Prometheus vs Datadog vs New Relic: Real Costs

Prometheus, Datadog, and New Relic compared for 2026 - real pricing at scale, hidden cost drivers, and which fits a Kubernetes-heavy stack.

5 min read•Aug 2026
Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter on EKS: scale-up speed, bin-packing, Spot handling, Auto Mode limits and a safe migration path, with v1 NodePool YAML.

11 min read•Aug 2026
GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE, EKS, and AKS compared for 2026 - control plane pricing, Autopilot vs Karpenter vs Node Auto Provisioning, and which platform actually fits your team.

5 min read•Aug 2026
K3s vs K8s vs MicroK8s: Which Distro in 2026?

K3s vs K8s vs MicroK8s: Which Distro in 2026?

Compare K3s, upstream Kubernetes and MicroK8s on footprint, datastores, HA and updates, and pick the right fit for edge, dev or production.

10 min read•Aug 2026
Canary Deployments with Argo Rollouts & Flagger

Canary Deployments with Argo Rollouts & Flagger

Ship to 5% of users first and auto-rollback on bad metrics: canary deployments on Kubernetes with Argo Rollouts, Flagger, and Gateway API.

11 min read•Jun 2026
OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry in practice: instrument a Node.js service, run a production Collector, sample traces and link metrics, logs and traces in Grafana.

11 min read•Jun 2026
Kubernetes Cost Optimization Without SLO Risk

Kubernetes Cost Optimization Without SLO Risk

Kubernetes clusters average about 8% CPU use. Cut waste safely with request rightsizing, autoscaling, spot, and OpenCost, keeping SLOs.

11 min read•Jun 2026
ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD compared for 2026: UI, multi-tenancy, Helm, image automation and pruning risks, with a clear guide to picking your GitOps engine.

10 min read•Jun 2026

Frequently Asked Questions

Is Implementing a Service Mesh with Istio and Linkerd free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Implementing a Service Mesh with Istio and Linkerd topic cover?

Learn how Istio and Linkerd add mTLS, canary releases, circuit breaking and observability to Kubernetes services without changing app code.

Does Implementing a Service Mesh with Istio and Linkerd include hands-on modules?

Yes - this topic has 1 attached module for hands-on practice.

Found a mistake, an outdated step or a broken link?