- Inspect the cluster and Istio control plane.
- Enable automatic sidecar injection for the
mesh-demonamespace. - Enforce STRICT mTLS using a PeerAuthentication.
- Use an AuthorizationPolicy to restrict which services can call the Payment API.
- Validate behavior with
istioctl analyzeand simple curl tests.
1. Verify cluster and workloads
Check Istio control-plane pods and workloads in themesh-demo namespace:
2. Enable automatic sidecar injection
Enable automatic sidecar injection for themesh-demo namespace:
3. Inspect the effective mTLS mode for a pod
Useistioctl x describe pod to see the effective PeerAuthentication mode for a workload. Provide the pod name:
Permissive mode allows both mTLS and plaintext connections. To enforce mTLS for all traffic in a namespace, apply a PeerAuthentication resource with
mode: STRICT.4. Enforce STRICT mTLS in the namespace
Create a PeerAuthentication that sets mTLS to STRICT for themesh-demo namespace. Save this as peer-auth-strict.yaml:
Enabling STRICT mTLS immediately will reject plaintext clients. Ensure all clients in the mesh have sidecars and valid identities before applying to production.
5. AuthorizationPolicy — restrict who can call the Payment API
mTLS handles encryption and identity verification, but not which services may call a particular API. Use Istio’s AuthorizationPolicy to control access. The example below allows only theweb-frontend service account to call payment-api endpoints under /api/* using GET and POST. Save as authz-policy.yaml:
selector.matchLabelsscopes the policy to pods labeledapp: payment-api.source.principalsuses the Istio/SPIFFE identity format:cluster.local/ns/<namespace>/sa/<serviceaccount>. Istio binds the TLS certificate identity to the Kubernetes service account.- The
operationblock restricts HTTP methods and paths.
6. Test the AuthorizationPolicy
From theorder-api deployment (not authorized), attempt to call the Payment API. This request should be rejected:
web-frontend deployment (authorized), call the same endpoint. The policy will allow the request; the application may return 404 if the path does not exist, but the important part is the policy decision:
web-frontend is allowed while the same request from order-api is rejected with 403. Istio enforces decisions at the sidecar, rejecting unauthorized requests before they reach the application container.
This explicit authentication and authorization model is core to a zero-trust networking approach.
7. Final validation and troubleshooting
Runistioctl analyze as a preflight to catch configuration issues (missing injection label, selector mismatches, port naming conventions, etc.):
Commands and resources (at-a-glance)
Summary
- Istio sidecars (Envoy) provide transparent mTLS for pod-to-pod traffic.
- Enable automatic injection on a namespace and restart workloads to inject proxies.
- Use
PeerAuthenticationto enforce STRICT mTLS across a namespace or per-workload. - Use
AuthorizationPolicyto explicitly control which identities (service accounts) can call particular services and operations. - Use
istioctl analyzeandistioctl x describe podto validate and troubleshoot your security posture.
- Istio documentation: https://istio.io/
- Istio security concepts (mTLS, PeerAuthentication, AuthorizationPolicy): https://istio.io/latest/docs/tasks/security/
- Kubernetes documentation: https://kubernetes.io/docs/