Skip to main content
RBAC controls who can interact with the Kubernetes API. But traffic between services inside the cluster is a different surface: by default pod-to-pod communication is unauthenticated and unencrypted. A compromised service can freely talk to any other service. Mutual TLS (mTLS) solves both problems: both sides of a connection verify each other’s identity using certificates, and all traffic is encrypted in transit. Istio implements mTLS transparently with Envoy sidecars so your application code does not need to change. In this lesson you’ll:
  • Inspect the cluster and Istio control plane.
  • Enable automatic sidecar injection for the mesh-demo namespace.
  • Enforce STRICT mTLS using a PeerAuthentication.
  • Use an AuthorizationPolicy to restrict which services can call the Payment API.
  • Validate behavior with istioctl analyze and simple curl tests.

1. Verify cluster and workloads

Check Istio control-plane pods and workloads in the mesh-demo namespace:
Example output:
Analyze the namespace for Istio configuration suggestions:
You may see messages like:
These are informational warnings that help harden your mesh configuration.

2. Enable automatic sidecar injection

Enable automatic sidecar injection for the mesh-demo namespace:
Note: The label affects newly created or restarted pods. Restart existing deployments to inject sidecars:
After the restart the pods should show 2/2 READY indicating Envoy sidecars are present:
Example output:
The sidecar transparently intercepts inbound and outbound traffic for the pod without modifying application code.

3. Inspect the effective mTLS mode for a pod

Use istioctl x describe pod to see the effective PeerAuthentication mode for a workload. Provide the pod name:
Example output before changing policy:
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 the mesh-demo namespace. Save this as peer-auth-strict.yaml:
Apply it:
Confirm the resource:
Example output:
Re-check a pod to verify the effective mode:
You should now see:
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 the web-frontend service account to call payment-api endpoints under /api/* using GET and POST. Save as authz-policy.yaml:
Key points:
  • selector.matchLabels scopes the policy to pods labeled app: payment-api.
  • source.principals uses the Istio/SPIFFE identity format: cluster.local/ns/<namespace>/sa/<serviceaccount>. Istio binds the TLS certificate identity to the Kubernetes service account.
  • The operation block restricts HTTP methods and paths.
Apply the policy:

6. Test the AuthorizationPolicy

From the order-api deployment (not authorized), attempt to call the Payment API. This request should be rejected:
Expected output:
From the 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:
Expected example output:
A 404 means the request passed Istio authorization but the application returned Not Found. The key outcome: request from 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

Run istioctl analyze as a preflight to catch configuration issues (missing injection label, selector mismatches, port naming conventions, etc.):
Typical informational outputs to address:
Use these messages to iteratively harden your configuration before promoting changes to production.

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 PeerAuthentication to enforce STRICT mTLS across a namespace or per-workload.
  • Use AuthorizationPolicy to explicitly control which identities (service accounts) can call particular services and operations.
  • Use istioctl analyze and istioctl x describe pod to validate and troubleshoot your security posture.
Links and references

Watch Video

Practice Lab