Skip to main content
RBAC controls who can interact with the Kubernetes API. But intra-cluster service-to-service traffic is unauthenticated and unencrypted by default: a compromised pod can communicate freely with other services. Mutual TLS (mTLS) provides both encryption in transit and identity verification between workloads. Istio implements mTLS transparently via sidecar proxies so your application code does not need to change. In this guide you’ll:
  • Verify cluster and namespace state,
  • Enable Istio automatic sidecar injection for the demo namespace,
  • Observe default mTLS behavior (PERMISSIVE),
  • Enforce STRICT mTLS with a PeerAuthentication resource,
  • Apply an AuthorizationPolicy to restrict which services may call the payment API,
  • Validate the policy via in-cluster curl requests,
  • Run istioctl analyze for a final diagnostic check.

1) Check current state

Confirm Istio control plane pods and application pods in the mesh-demo namespace. Before enabling injection, application pods run without the sidecar (single container). Check Istio control plane pods:
Example output:
Check application pods in the demo namespace (no sidecars yet):
Example output:
Run an initial analysis (recommended):
Example informational output:

2) Enable automatic sidecar injection and restart workloads

Label the namespace to enable automatic Istio sidecar injection. Then restart the deployments so new pods are created with the sidecar proxy.
After pods restart, each workload should have two containers (application + istio-proxy). Verify:
Example output after restart:
Inspect a pod to see the effective mTLS mode:
Look for:
Permissive mTLS accepts both plain-text (HTTP) and mTLS connections. It’s a safe default during setup because it allows mixed clients while sidecars are being rolled out, but it does not enforce encryption or strongly verify caller identity.

3) Enforce strict mTLS (PeerAuthentication)

To require encrypted, authenticated connections between workloads in mesh-demo, create a PeerAuthentication resource with mtls.mode: STRICT. peer-auth-strict.yaml:
Apply it:
Verify:
Expected spec summary:
Applying PeerAuthentication with mode: STRICT will cause any plain-text (non-mTLS) connections to fail. Ensure all workloads in the namespace have sidecars injected and are up-to-date before applying strict mTLS to avoid service disruption.

4) Restrict calls with an AuthorizationPolicy

mTLS ensures encrypted, authenticated connections, but it does not restrict which workloads can connect to others. Use an AuthorizationPolicy to enforce a zero-trust pattern: allow only specific principals (service accounts) to call the payment API. Create this AuthorizationPolicy scoped to the payment-api workload: authz-policy.yaml:
Key notes:
  • selector.matchLabels scopes the policy to pods labeled app: payment-api.
  • principals uses the SPIFFE identity form (here: cluster.local/ns/mesh-demo/sa/web-frontend) derived from the caller’s service account.
  • operation.methods limits allowed HTTP methods. You can also add paths or other HTTP attributes.
Apply the policy:
Table: Resources created

5) Validate behavior with in-cluster curl

Test from a pod with an unauthorized identity (order-api). The request should be rejected by Istio (HTTP 403):
Expected output:
Test from the allowed principal (web-frontend). The request should be permitted; the upstream service may return 404 if the path is missing, which still indicates the request was authorized and reached the service:
Expected output (example):
Interpretation:
  • 403 from order-api: Istio denied the request at the sidecar (authorization failure).
  • 404 from web-frontend: Policy allowed the request and the call reached the payment-api, but the specific path was not found.
This demonstrates zero-trust networking: connections are both authenticated (mTLS) and authorized (AuthorizationPolicy).

6) Re-run analysis

Run istioctl analyze to surface configuration issues such as namespace injection, port naming, selector mismatches, or other diagnostic hints:
Example informational warnings:
Use istioctl analyze as a routine pre-deployment check before pushing broader changes to production.
Summary
  • Enabled Istio sidecar injection for the mesh-demo namespace.
  • Confirmed PERMISSIVE mTLS initially, then enforced STRICT mTLS using a PeerAuthentication.
  • Applied an AuthorizationPolicy to restrict which service account can call the payment API and limited allowed operations.
  • Validated enforcement with in-cluster curl tests: unauthorized requests were rejected by Istio, authorized requests reached the service.
  • Re-ran istioctl analyze to surface configuration warnings to address.
Links and references

Watch Video

Practice Lab