Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 36 ยท Traffic Management

Service Entries and Egress Control

Register external services with ServiceEntry, choose REGISTRY_ONLY outbound policy, apply timeouts to external calls and limit sidecar scope with Sidecar.

Traffic management so far concerned calls inside the mesh. Real applications also call the outside world: payment APIs, managed databases, SaaS tools. By default Istio lets sidecars send such traffic straight out, treating it as opaque TCP. A ServiceEntry makes an external service a first-class citizen of the mesh so that routing, timeouts, retries and telemetry apply to it, and an outbound policy can forbid everything that is not registered.

YAML is read-only here. The Python stand-ins model allow-listing, not Istio's implementation.

ServiceEntry

YAML
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: payments-api
  namespace: shop
spec:
  hosts:
    - api.payments.example.com
  location: MESH_EXTERNAL
  resolution: DNS
  ports:
    - number: 443
      name: tls
      protocol: TLS
  exportTo:
    - "."

Fields:

  • hosts: the DNS name callers use.
  • location: MESH_EXTERNAL for services outside, MESH_INTERNAL for non-pod services you consider inside the mesh (like VMs).
  • resolution: NONE (use the original destination IP), STATIC (listed endpoints), or DNS (resolve the host).
  • ports: name and protocol; use TLS or HTTPS for encrypted traffic you do not terminate. If the application speaks plain http to the external host, the proxy can apply full L7 features.
  • exportTo: which namespaces can see the entry; "." means only this namespace, "*" all.

After this, the entry appears in istioctl proxy-config clusters and in metrics, so you can see which external hosts the shop calls and how often they fail.

Timeouts and retries for external calls

A VirtualService can attach to the external host (when the app speaks plain HTTP to it, or at an egress gateway):

YAML
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: payments-api
  namespace: shop
spec:
  hosts:
    - api.payments.example.com
  http:
    - route:
        - destination:
            host: api.payments.example.com
      timeout: 3s

For HTTPS traffic the proxy sees only encrypted bytes and the SNI name, so you can route or allow by host name but not by path, unless you terminate TLS at the proxy (TLS origination: the app sends HTTP, a DestinationRule with tls.mode: SIMPLE upgrades it to HTTPS).

Locking down egress

The mesh-wide setting outboundTrafficPolicy decides what to do with traffic to unknown hosts:

YAML
# in meshConfig (IstioOperator or Helm values)
meshConfig:
  outboundTrafficPolicy:
    mode: REGISTRY_ONLY
  • ALLOW_ANY (default): unknown destinations pass through.
  • REGISTRY_ONLY: only hosts known to the mesh (Kubernetes Services and ServiceEntries) are reachable; others get a 502 with response flag NR/UH style errors.

REGISTRY_ONLY plus a reviewed list of ServiceEntries gives you an allow-list of external dependencies, which is a strong defence against data exfiltration by a compromised workload. Note that a determined attacker may bypass a sidecar; combine it with Kubernetes network policy or an egress gateway that is the only pod allowed to leave the cluster (see chapter 6).

Keeping proxies small with Sidecar

In a large mesh every proxy by default knows every service. The Sidecar resource narrows that:

YAML
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: default
  namespace: shop
spec:
  egress:
    - hosts:
        - "./*"
        - "istio-system/*"
        - "payments/api.payments.svc.cluster.local"

Proxies in shop now load config only for services in their namespace, istio-system, and that one payments service. Less config means lower memory and faster pushes. A call to anything not listed fails, so list what each namespace truly needs.

Stand-ins

Python Stand-in: REGISTRY_ONLY outbound policy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: what does a Sidecar scope remove?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a ServiceEntry do?

    ServiceEntry describes a host and ports the mesh does not discover on its own.
  2. 2. What does outboundTrafficPolicy.mode: REGISTRY_ONLY do?

    Unknown external hosts fail, so you maintain an explicit allow-list with ServiceEntries.
  3. 3. For HTTPS traffic left encrypted, what can the proxy see?

    Without TLS origination or termination, L7 details are hidden; routing is by host name.
  4. 4. Why use the Sidecar resource?

    A scoped egress list shrinks proxy config in large meshes.

Summary

  • ServiceEntry registers external hosts so they get routing, timeouts and metrics.
  • resolution and location describe how to reach them and whether they are inside the mesh.
  • REGISTRY_ONLY turns the registry into an egress allow-list; pair it with an egress gateway or network policy.
  • TLS origination lets the proxy upgrade plain HTTP to HTTPS and see paths.
  • The Sidecar resource scopes proxy config for large meshes.

Next: mTLS and Peer Authentication