Out of the box, an Istio sidecar lets your application call any host on the internet. Requests to destinations that Istio doesn't know about go to a cluster called PassthroughCluster, which forwards them to whatever IP the application asked for. That makes the first install painless, but you lose most of the mesh's telemetry and control for that traffic, and nobody has a list of what the workloads actually talk to.
The REGISTRY_ONLY outbound traffic policy flips the default. A sidecar then only forwards traffic to hosts in its service registry, which means Kubernetes services and hosts you declare with a ServiceEntry. This guide switches a mesh to REGISTRY_ONLY without surprise outages, allows external HTTPS hosts, narrows egress per namespace with the Sidecar resource and shows how to read the failures. It assumes sidecar mode on Istio 1.32.
What REGISTRY_ONLY does and does not do
The setting lives in mesh config as meshConfig.outboundTrafficPolicy.mode. In Istio 1.32 it takes three values. ALLOW_ANY is the default and passes unknown traffic through. REGISTRY_ONLY drops it. ALLOW_ANY_DYNAMIC_DNS also allows unknown destinations but resolves them through DNS, and it can't be set on a Sidecar resource.
When a sidecar in REGISTRY_ONLY mode sees traffic for an unknown host, it sends it to BlackHoleCluster. That is a static Envoy cluster with no endpoints, so nothing reaches the destination. Plain HTTP on a port where the sidecar has HTTP routes, such as port 80, hits a catch-all virtual host named block_all that answers with a direct 502 response. TLS and raw TCP connections fall through to a TCP proxy that points at BlackHoleCluster, so the client sees its connection closed instead of an HTTP status. With curl against an HTTPS URL that usually shows up as exit code 35, a failed TLS handshake.
Be clear about what this buys you. The Istio API reference says plainly that REGISTRY_ONLY is not an outbound traffic security policy or a firewall. A workload that can bypass its sidecar, or that runs without one, is not restricted at all. The setting exists so that missing ServiceEntry configuration fails loudly. If you need enforcement, combine it with Kubernetes network policies and an egress gateway.
Step 1: turn on access logs and find current external traffic
You want to know which external hosts your workloads call before you block anything. Envoy access logs are the easiest source. If your install does not write them yet, set meshConfig.accessLogFile to /dev/stdout. An empty value disables access logging, which is the default outside the demo profile.
Rerun the istioctl install command you originally used, with the extra flag added. The Istio docs change mesh settings this way, so keep the flags you passed the first time.
istioctl install --set meshConfig.accessLogFile=/dev/stdout
Let the mesh run for a while, long enough to cover nightly jobs and other periodic tasks. Then search the istio-proxy container logs for PassthroughCluster. In Istio's default text format, the second-to-last field of each line is the requested server name, so for HTTPS traffic it holds the SNI host the application asked for.
kubectl logs deploy/orders -n shop -c istio-proxy --since=24h \
| grep PassthroughCluster \
| awk '{print $(NF-1)}' | sort | uniq -c | sort -rn
Repeat this for each workload, or pull the same data from your log backend. If you run Prometheus, istio_requests_total and istio_tcp_connections_closed_total with destination_service_name="PassthroughCluster" show the same traffic as metrics. For TCP traffic the metric carries no host name, so the access log is the better tool. Write down every host and port you find. That list becomes your set of service entries.
Step 2: register external HTTPS hosts with ServiceEntry
A ServiceEntry adds a host to Istio's registry, so the sidecar builds a real cluster for it with its own name, stats and settings. Create one per external dependency, and give the HTTPS port protocol: HTTPS. Most applications start TLS themselves, so the sidecar can't read the request. Instead it routes the connection by the SNI host in the TLS handshake.
Keeping the entries in one namespace makes them easy to review and lets each team import only what it needs later on. The example below uses a namespace called egress-hosts.
kubectl create namespace egress-hosts
kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: google
namespace: egress-hosts
spec:
hosts:
- www.google.com
ports:
- number: 443
name: https
protocol: HTTPS
resolution: DNS
location: MESH_EXTERNAL
EOF
Use resolution: DNS for named external hosts. With DNS, the sidecar ignores the IP the application connected to and resolves the host itself. With NONE, it forwards to the original destination IP. The Istio egress task warns that NONE opens a hole, at least for plain HTTP, since a client could send a trusted Host header to an untrusted IP and the sidecar would let it through.
Leave exportTo unset for now. A service entry with no exportTo is visible in every namespace. You will narrow visibility with the Sidecar resource in step 5, which keeps the policy in the namespace that consumes the host.
If a dependency uses a plain HTTP port, declare it with protocol: HTTP on port 80 instead. Don't label port 443 as HTTP for a client that sends TLS. Envoy would try to parse encrypted bytes as HTTP and fail.
Step 3: switch the mesh to REGISTRY_ONLY
Once the service entries cover everything in your list, change the mode. You can add entries while the mesh is still in ALLOW_ANY, and they take effect for those hosts right away. Only the unknown hosts change behavior when you switch.
With istioctl, add the setting to your original install command.
istioctl install --set meshConfig.accessLogFile=/dev/stdout \
--set meshConfig.outboundTrafficPolicy.mode=REGISTRY_ONLY
If you install from an IstioOperator file, add the field there instead.
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
meshConfig:
accessLogFile: /dev/stdout
outboundTrafficPolicy:
mode: REGISTRY_ONLY
Pods don't need a restart. Istiod pushes the new configuration to the sidecars, which can take a few seconds. Check that the setting reached the mesh config.
kubectl get configmap istio -n istio-system -o jsonpath='{.data.mesh}' | grep -A1 outboundTrafficPolicy
Step 4: test allowed and blocked calls
Run curl from a sidecar-injected pod. The registered host should still answer, and an unregistered one should fail. The commands below use the curl sample from the Istio repository, but any pod with curl and a sidecar works.
export SOURCE_POD=$(kubectl get pod -l app=curl -o jsonpath='{.items..metadata.name}')
kubectl exec "$SOURCE_POD" -c curl -- curl -sSI https://www.google.com | grep "HTTP/"
kubectl exec "$SOURCE_POD" -c curl -- curl -sI https://edition.cnn.com | grep "HTTP/"
The first call returns HTTP/2 200. The second has no service entry, so the sidecar closes the connection during the TLS handshake and kubectl reports the curl failure.
HTTP/2 200
command terminated with exit code 35
An unregistered plain HTTP host on port 80 behaves differently. The sidecar parses the request, matches the block_all virtual host and answers HTTP/1.1 502 Bad Gateway itself. So if one team reports 502s and another reports TLS errors right after the switch, they likely hit the same cause.
Step 5: scope egress per namespace with Sidecar
Mesh-wide REGISTRY_ONLY still lets every namespace reach every registered host. The Sidecar resource narrows that. Its egress.hosts list uses namespace/dnsName entries and decides which services a sidecar knows about. Traffic to anything outside that list is treated as unmatched, and under REGISTRY_ONLY unmatched traffic goes to BlackHoleCluster.
The Sidecar below lets workloads in shop reach services in their own namespace, the control plane in istio-system, and one external host from egress-hosts. It also sets the outbound policy for this namespace, so the namespace stays locked down even if the mesh default changes.
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
name: default
namespace: shop
spec:
outboundTrafficPolicy:
mode: REGISTRY_ONLY
egress:
- hosts:
- "./*"
- "istio-system/*"
- "egress-hosts/www.google.com"
Name it default and leave out workloadSelector. Each namespace can have only one Sidecar without a selector, and Istio's behavior is undefined if there are two. A Sidecar in the root namespace, istio-system by default, applies to every namespace that doesn't have its own.
Don't rely on Sidecar scoping alone. Under ALLOW_ANY, a host missing from egress.hosts is passed through, not blocked. The API reference calls this a common misunderstanding. Scoping trims configuration, and the outbound policy decides what happens to everything that was trimmed.
Step 6: verify with istioctl proxy-config and the access log
When a call fails, first check whether the client's sidecar has a cluster for the host. An outbound cluster for www.google.com on port 443 means the ServiceEntry reached the proxy and the Sidecar imported it.
istioctl proxy-config cluster "$SOURCE_POD" --fqdn www.google.com
An empty result for the host points at the configuration. Look for a typo in hosts, an exportTo that hides the entry from this namespace, or a Sidecar that doesn't import it. For plain HTTP, the port's route table shows the fallback. In REGISTRY_ONLY mode it contains the block_all virtual host.
istioctl proxy-config route "$SOURCE_POD" --name 80 -o json | grep -n block_all
The access log tells you what got blocked. Blocked TLS and TCP connections list BlackHoleCluster as the upstream cluster, and the second-to-last field still holds the SNI host, so the earlier one-liner works with the cluster name swapped. Blocked HTTP requests end with the route name block_all and show the requested host in the authority field.
kubectl logs deploy/orders -n shop -c istio-proxy --since=1h \
| grep -E 'BlackHoleCluster|block_all'
Each host in that output is either a dependency that needs a ServiceEntry and a Sidecar import, or a call you are glad to have stopped. Keep checking for a few days after the switch, since rare jobs show up late.