

- Intercepting inbound and outbound traffic for the workload
- Enforcing mTLS if configured (not enabled by default)
- Providing traffic-management primitives: load balancing, timeouts, retries, logging, circuit breaking, rate limiting, etc.

Enable automatic sidecar injection for namespaces that should take advantage of Istio features. You can label a namespace with
istio-injection=enabled before creating pods to have Envoy injected automatically.istio-system, and deny all other egress.

Restricting egress with a Sidecar resource
To override the default (broad) sidecar behavior for a namespace, create aSidecar resource that defines allowed egress hosts. The example below restricts the payments namespace so workloads can only call:
- workloads in the same namespace (
./*) - workloads in the
appnamespace (app/*) - workloads in
istio-system(istio-system/*)
./*matches all services in the same namespace as the Sidecar (i.e.,payments).app/*matches all services in theappnamespace.istio-system/*matches services in the Istio control-plane namespace.
kubectl apply -f sidecar.yaml (or your preferred deployment method). Only workloads in the payments namespace that have an Envoy sidecar will be affected by this config.
A
Sidecar or PeerAuthentication resource created in a namespace without Envoy-injected workloads will have no practical effect. Ensure the namespace is labeled for Istio injection or that pods were injected manually.Enforcing mTLS with PeerAuthentication
Istio’s default PeerAuthentication mode is permissive, which means workloads accept either mTLS or plaintext connections. To require mTLS for a namespace, create aPeerAuthentication resource and set mtls.mode: STRICT. Example for the app namespace:
- Any client calling workloads in the
appnamespace must use mTLS. - Clients without an Envoy sidecar (or not participating in the mesh) will be unable to connect.
Per-workload Sidecar example
You can scope Sidecar resources to specific workloads by usingworkloadSelector. The following example targets pods with label app: ratings in the bookinfo namespace. It configures a custom ingress port (9080 bound to a UDS) and restricts egress to bookinfo/* and istio-system/* on port 9080.
- Accepts HTTP traffic on port 9080 and forwards it to the workload via the specified Unix Domain Socket.
- Limits egress to the
bookinfoandistio-systemnamespaces on that same port.
Quick reference
Where to find more details
- Istio Sidecar reference: https://istio.io/latest/docs/reference/config/networking/sidecar/
- Istio PeerAuthentication reference: https://istio.io/latest/docs/reference/config/security/peer_authentication/
- Identify when a namespace has injection enabled,
- Read and author
Sidecarresources to restrict egress/ingress, - Enforce mTLS via
PeerAuthentication.