Lesson 06 of 9 · Modules
Lab: from no mesh to STRICT mTLS
A guided lab from a cluster with no mesh to enforced, verified pod-to-pod mTLS. Prove traffic is plain text, install Istio with Helm (or istioctl), inject sidecars, check auto mTLS in PERMISSIVE mode, enforce STRICT, inspect the certificate, prove encryption with a packet capture, add identity-based authorization, and verify every step with or without istioctl.
You have a cluster with no mesh, so traffic between pods is plain text. In this lab you prove that, add Istio, turn on mTLS, enforce it, and verify it from several angles. Use a lab cluster (kind, minikube or a dev cluster); everything is removed in the last step.
0 Pre-checks → 1 Demo apps → 2 Prove plain text → 3 Install Istio → 4 Inject sidecars
→ 5 Check mTLS (PERMISSIVE) → 6 Enforce STRICT → 7 Inspect the certificate
→ 8 Prove encryption → 9 Authorization → 10 Mesh-wide and clean-up
Step 0: pre-checks
$ kubectl config current-context
$ kubectl version
$ kubectl get nodes -o wide
Make sure you are on the right cluster and it has room for istiod (about 500 MB of memory).
Step 1: deploy the demo apps (no mesh yet)
One server (httpbin, which echoes the headers it receives) and two clients: sleep in demo will join the mesh, and sleep in legacy will stay outside it.
apiVersion: v1
kind: ServiceAccount
metadata: { name: httpbin, namespace: demo }
---
apiVersion: v1
kind: ServiceAccount
metadata: { name: sleep, namespace: demo }
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: httpbin, namespace: demo }
spec:
replicas: 1
selector: { matchLabels: { app: httpbin } }
template:
metadata: { labels: { app: httpbin } }
spec:
serviceAccountName: httpbin
containers:
- name: httpbin
image: mccutchen/go-httpbin
ports: [ { containerPort: 8080 } ]
---
apiVersion: v1
kind: Service
metadata: { name: httpbin, namespace: demo }
spec:
selector: { app: httpbin }
ports: [ { name: http, port: 8000, targetPort: 8080 } ]
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: sleep, namespace: demo }
spec:
replicas: 1
selector: { matchLabels: { app: sleep } }
template:
metadata: { labels: { app: sleep } }
spec:
serviceAccountName: sleep
containers:
- name: sleep
image: curlimages/curl
command: ["sleep", "infinity"]
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: sleep, namespace: legacy }
spec:
replicas: 1
selector: { matchLabels: { app: sleep } }
template:
metadata: { labels: { app: sleep } }
spec:
containers:
- name: sleep
image: curlimages/curl
command: ["sleep", "infinity"]
Save it as demo.yaml, then:
$ kubectl create namespace demo
$ kubectl create namespace legacy
$ kubectl apply -f demo.yaml
$ kubectl -n demo rollout status deploy/httpbin
$ kubectl get pods -n demo
NAME READY STATUS RESTARTS AGE
httpbin-7c9d8f6b5-abcde 1/1 Running 0 20s
sleep-5d8f7c9b6-fghij 1/1 Running 0 20s
1/1 means one container: no sidecar yet.
Step 2: prove the traffic is plain text
$ kubectl -n demo exec deploy/sleep -- curl -s http://httpbin.demo:8000/headers
{ "headers": { "Accept": ["*/*"], "Host": ["httpbin.demo:8000"], "User-Agent": ["curl/8.x"] } }
There is no X-Forwarded-Client-Cert header. For the strongest proof, capture packets on the server pod and call it again from a second terminal:
$ POD=$(kubectl -n demo get pod -l app=httpbin -o jsonpath='{.items[0].metadata.name}')
$ kubectl -n demo debug -it $POD --image=nicolaka/netshoot --profile=netadmin -- \
tcpdump -i eth0 -A -s0 'tcp port 8080'
GET /headers HTTP/1.1
Host: httpbin.demo:8000
User-Agent: curl/8.x
Readable text on the wire means no encryption. If Pod Security Admission blocks kubectl debug, skip the capture; later steps prove mTLS in other ways.
Step 3: install Istio
You only need the control plane, istiod, which is also the mesh CA. Choose one option.
Option A: Helm, the production way (pin versions and apply through GitOps):
$ helm repo add istio https://istio-release.storage.googleapis.com/charts
$ helm repo update
$ helm install istio-base istio/base -n istio-system --create-namespace \
--set defaultRevision=default --wait
$ helm install istiod istio/istiod -n istio-system --wait
$ helm ls -n istio-system
NAME NAMESPACE REVISION STATUS CHART APP VERSION
istio-base istio-system 1 deployed base-1.x.y 1.x.y
istiod istio-system 1 deployed istiod-1.x.y 1.x.y
Option B: istioctl, quick for labs:
$ istioctl x precheck
$ istioctl install --set profile=minimal -y
Either way:
$ kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
istiod-6d8f9c7b5d-xyz12 1/1 Running 0 40s
Keep istioctl on your laptop even if you install with Helm; it is the best debugging tool. Match its version to the control plane.
Step 4: inject sidecars
$ kubectl label namespace demo istio-injection=enabled
$ kubectl -n demo rollout restart deploy
$ kubectl -n demo rollout status deploy/httpbin
$ kubectl get pods -n demo
NAME READY STATUS RESTARTS AGE
httpbin-6f7d9c8b4-klmno 2/2 Running 0 15s
sleep-7b6c5d4e3-pqrst 2/2 Running 0 15s
2/2 means app + istio-proxy. Check the proxies:
$ istioctl proxy-status # every sidecar SYNCED
$ kubectl -n demo exec deploy/sleep -c istio-proxy -- pilot-agent request GET server_info | grep '"state"'
"state": "LIVE",
Step 5: check mTLS in PERMISSIVE mode
Istio's auto mTLS already uses mTLS between two sidecars. PERMISSIVE (the default) also still accepts plain text.
$ kubectl -n demo exec deploy/sleep -c sleep -- curl -s http://httpbin.demo:8000/headers \
| grep -A1 -i x-forwarded-client-cert
"X-Forwarded-Client-Cert": [
"By=spiffe://cluster.local/ns/demo/sa/httpbin;Hash=…;Subject=\"\";URI=spiffe://cluster.local/ns/demo/sa/sleep"
The header appears only on mTLS connections, and URI=…/sa/sleep is the caller's verified identity. The un-meshed pod still gets in:
$ kubectl -n legacy exec deploy/sleep -- curl -s -o /dev/null -w "%{http_code}\n" http://httpbin.demo:8000/get
200
Step 6: enforce STRICT
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: default, namespace: demo }
spec:
mtls: { mode: STRICT }
$ kubectl -n demo exec deploy/sleep -c sleep -- curl -s -o /dev/null -w "%{http_code}\n" http://httpbin.demo:8000/get
200
$ kubectl -n legacy exec deploy/sleep -- curl -s -o /dev/null -w "%{http_code}\n" http://httpbin.demo:8000/get
000
command terminated with exit code 56
The meshed client works; the plain-text client is reset. Confirm the mode:
$ istioctl x describe pod $(kubectl -n demo get pod -l app=httpbin -o jsonpath='{.items[0].metadata.name}') -n demo
Effective PeerAuthentication:
Workload mTLS mode: STRICT
$ kubectl get peerauthentication -A # without istioctl
NAMESPACE NAME MODE AGE
demo default STRICT 1m
Count mTLS vs plain-text requests from the server's own metrics:
$ kubectl -n demo exec deploy/httpbin -c istio-proxy -- pilot-agent request GET stats/prometheus \
| grep '^istio_requests_total' | grep -o 'connection_security_policy="[a-z_]*"' | sort | uniq -c
3 connection_security_policy="mutual_tls"
1 connection_security_policy="none"
Order matters in production
Inject sidecars everywhere, watch connection_security_policy="none" (or Kiali) until no plain-text callers remain, and only then switch to STRICT. Switching first breaks every caller without a sidecar.
Step 7: inspect the certificate
With istioctl:
$ istioctl proxy-config secret deploy/httpbin -n demo
RESOURCE NAME TYPE STATUS VALID CERT SERIAL NUMBER NOT AFTER NOT BEFORE
default Cert Chain ACTIVE true 1a2b3c… 2026-11-09T10:00:00Z 2026-11-08T09:58:00Z
ROOTCA CA ACTIVE true 4d5e6f… 2036-11-06T… 2026-11-08T…
$ istioctl proxy-config secret deploy/httpbin -n demo -o json \
| jq -r '.dynamicActiveSecrets[0].secret.tlsCertificate.certificateChain.inlineBytes' \
| base64 -d | openssl x509 -noout -issuer -dates -ext subjectAltName,extendedKeyUsage
issuer=O = cluster.local
notBefore=Nov 8 09:58:00 2026 GMT
notAfter=Nov 9 09:58:00 2026 GMT
X509v3 Subject Alternative Name: critical
URI:spiffe://cluster.local/ns/demo/sa/httpbin
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
Without istioctl, ask Envoy's admin API through pilot-agent, or port-forward it:
$ kubectl -n demo exec deploy/httpbin -c istio-proxy -- pilot-agent request GET certs
$ kubectl -n demo port-forward deploy/httpbin 15000:15000 # then, in a second terminal:
$ curl -s localhost:15000/certs | jq '.certificates[].cert_chain[] | {serial_number, subject_alt_names, expiration_time}'
$ kubectl -n demo get configmap istio-ca-root-cert -o jsonpath='{.data.root-cert\.pem}' \
| openssl x509 -noout -subject -dates
| You see | It means |
|---|---|
SAN spiffe://…/ns/demo/sa/httpbin |
Identity = namespace + service account, not IP |
| Valid for 24 hours | Short-lived and rotated automatically |
| EKU server + client | The same certificate serves both sides of mTLS |
Issuer cluster.local |
istiod's self-signed root; use your own CA in production |
Envoy redacts private keys in its admin output. Never print ca-key.pem from the CA Secret: whoever has it can mint any identity in the mesh.
Step 8: prove it is encrypted
Repeat the capture from step 2:
$ kubectl -n demo debug -it $POD --image=nicolaka/netshoot --profile=netadmin -- \
tcpdump -i eth0 -A -s0 'tcp port 8080'
E..<..@.@.....
.....\.x..R.....<binary>..*.>.Zq..
No readable GET /headers. The app still sends plain HTTP to its own sidecar inside the pod; encryption happens between the two sidecars, so no code change was needed.
Step 9: who may call whom
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: { name: httpbin-allow-sleep, namespace: demo }
spec:
selector: { matchLabels: { app: httpbin } }
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/demo/sa/sleep"]
Now create an intruder: meshed, valid mTLS, different service account.
$ kubectl -n demo create serviceaccount intruder
$ kubectl -n demo run intruder --image=curlimages/curl \
--overrides='{"spec":{"serviceAccountName":"intruder"}}' -- sleep infinity
$ kubectl -n demo wait --for=condition=Ready pod/intruder
$ kubectl -n demo exec deploy/sleep -c sleep -- curl -s -o /dev/null -w "%{http_code}\n" http://httpbin.demo:8000/get
200
$ kubectl -n demo exec intruder -c intruder -- curl -s -w "\n%{http_code}\n" http://httpbin.demo:8000/get
RBAC: access denied
403
Being inside the network, or even holding a valid certificate, is not enough: the identity must be explicitly allowed.
Step 10: mesh-wide STRICT and clean-up
In a real cluster, set STRICT once for the whole mesh in the root namespace:
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: default, namespace: istio-system }
spec:
mtls: { mode: STRICT }
Clean up the lab:
$ kubectl delete namespace demo legacy
$ kubectl delete peerauthentication default -n istio-system --ignore-not-found
# installed with Helm:
$ helm uninstall istiod -n istio-system
$ helm uninstall istio-base -n istio-system
$ kubectl delete namespace istio-system
$ kubectl get crd -o name | grep 'istio.io' | xargs kubectl delete # Helm keeps CRDs on purpose
# installed with istioctl:
$ istioctl uninstall --purge -y && kubectl delete namespace istio-system
What you verified, and how
| Check | With istioctl | With kubectl / Helm only | Proves |
|---|---|---|---|
| Istio installed | istioctl version |
helm ls -n istio-system |
Control plane running |
| Sidecar present | kubectl get pods → 2/2 |
same | Proxy injected |
| Proxies healthy | istioctl proxy-status |
pilot-agent request GET server_info |
Envoy live and configured |
| Connection is mTLS | X-Forwarded-Client-Cert | same | Caller's SPIFFE ID verified |
| Policy mode | istioctl x describe pod |
kubectl get peerauthentication -A |
STRICT in effect |
| Plain text rejected | legacy curl → exit 56 | same | Enforcement works |
| Certificate | istioctl proxy-config secret |
pilot-agent request GET certs |
Identity, issuer, 24h lifetime |
| On the wire | tcpdump | same | No readable payload |
| Authorization | intruder → 403 | same | Identity-based access |
| Fleet-wide | istio_requests_total{connection_security_policy="mutual_tls"} |
same | Share of mTLS traffic |
Going deeper
- Repeat the lab with ambient mode (
--set profile=ambienton istiod plus theistio/cniandistio/ztunnelcharts) and compare: no sidecars, no restarts, mTLS done by the node's ztunnel. - Install with a plug-in CA: create an intermediate from your own root, store it in the
cacertsSecret before installing istiod, and check the new issuer in step 7. - Wait 12+ hours and run step 7 again: a new serial number shows automatic rotation.
Recap
- Install istiod (Helm for production, istioctl for labs), label the namespace, restart pods to inject sidecars.
- Auto mTLS starts immediately in PERMISSIVE; enforce STRICT once no plain-text callers remain.
- Verify from several angles: the XFCC header, the policy mode, the certificate, a packet capture, and metrics.
- Add AuthorizationPolicies so only named identities can call each service.
- Everything istioctl shows can also be read with kubectl and Envoy's admin API.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.