- 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 analyzefor a final diagnostic check.
1) Check current state
Confirm Istio control plane pods and application pods in themesh-demo namespace. Before enabling injection, application pods run without the sidecar (single container).
Check Istio control plane pods:
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.istio-proxy). Verify:
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 inmesh-demo, create a PeerAuthentication resource with mtls.mode: STRICT.
peer-auth-strict.yaml:
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 thepayment-api workload:
authz-policy.yaml:
selector.matchLabelsscopes the policy to pods labeledapp: payment-api.principalsuses the SPIFFE identity form (here:cluster.local/ns/mesh-demo/sa/web-frontend) derived from the caller’s service account.operation.methodslimits allowed HTTP methods. You can also addpathsor other HTTP attributes.
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):404 if the path is missing, which still indicates the request was authorized and reached the service:
403fromorder-api: Istio denied the request at the sidecar (authorization failure).404fromweb-frontend: Policy allowed the request and the call reached the payment-api, but the specific path was not found.
6) Re-run analysis
Runistioctl analyze to surface configuration issues such as namespace injection, port naming, selector mismatches, or other diagnostic hints:
istioctl analyze as a routine pre-deployment check before pushing broader changes to production.
Summary
- Enabled Istio sidecar injection for the
mesh-demonamespace. - 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 analyzeto surface configuration warnings to address.