Every production Kubernetes cluster talks to the outside world. Your services call payment APIs, connect to managed databases, push events to SaaS analytics platforms, and reach legacy systems that will never run inside the mesh. By default, Istio lets all outbound traffic flow freely — or blocks it entirely if you flip outboundTrafficPolicy to REGISTRY_ONLY. Neither extreme gives you what you actually need: selective, observable, policy-controlled access to external services.
That is exactly what Istio ServiceEntry solves. It registers external endpoints in the mesh’s internal service registry so that Envoy sidecars can apply the same traffic management, security, and observability features to outbound calls that you already enjoy for east-west traffic. No new proxies, no egress gateways required for the basic case — just a YAML resource that tells the mesh “this external thing exists, and here is how to reach it.”
In this guide, I will walk through every field of the ServiceEntry spec, explain the four DNS resolution modes with real-world use cases, and show production-ready patterns for external APIs, databases, TCP services, and legacy workloads. We will also cover how to combine ServiceEntry with DestinationRule and VirtualService to get circuit breaking, retries, connection pooling, and even sticky sessions for external dependencies.
What Is a ServiceEntry
Istio maintains an internal service registry that merges Kubernetes Services with any additional entries you declare. When a sidecar proxy needs to decide how to route a request, it consults this registry. Services inside the mesh are automatically registered. Services outside the mesh are not — unless you create a ServiceEntry.
A ServiceEntry is a custom resource that adds an entry to the mesh’s service registry. Once registered, the external service becomes a first-class citizen: Envoy generates clusters, routes, and listeners for it, which means you get metrics (istio_requests_total), access logs, distributed traces, mTLS origination, retries, timeouts, circuit breaking — the full Istio feature set.
Without a ServiceEntry, outbound traffic to an external host either passes through as a raw TCP connection (in ALLOW_ANY mode) with no telemetry, or gets dropped with a 502/503 (in REGISTRY_ONLY mode). Both outcomes are undesirable in production. The ServiceEntry bridges that gap.
ServiceEntry Anatomy: All Fields Explained
Let us look at a complete ServiceEntry and then break down each field.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: external-api
namespace: production
spec:
hosts:
- api.stripe.com
location: MESH_EXTERNAL
ports:
- number: 443
name: https
protocol: TLS
resolution: DNS
exportTo:
- "."
- "istio-system"hosts
A list of hostnames associated with the service. For external services, this is typically the DNS name your application uses (e.g., api.stripe.com). For services using HTTP protocols, the hosts field is matched against the HTTP Host header. For non-HTTP protocols and services without a DNS name, you can use a synthetic hostname and pair it with addresses or static endpoints.
addresses
Optional virtual IP addresses associated with the service. Useful for TCP services where you want to assign a VIP that the sidecar will intercept. Not required for HTTP/HTTPS services that use hostname-based routing.
ports
The ports on which the external service is exposed. Each port needs a number, name, and protocol. The protocol matters: setting it to TLS tells Envoy to perform SNI-based routing without terminating TLS. Setting it to HTTPS means HTTP over TLS. For databases, you’ll typically use TCP.
location
MESH_EXTERNAL or MESH_INTERNAL. Use MESH_EXTERNAL for services outside your cluster (third-party APIs, managed databases). Use MESH_INTERNAL for services inside your infrastructure that are not part of the mesh — for example, VMs running in the same VPC that do not have a sidecar, or a Kubernetes Service in a namespace without injection enabled. The location affects how mTLS is applied and how metrics are labeled.
resolution
How the sidecar resolves the endpoint addresses. This is the most critical field and I will dedicate the next section to it. Options: NONE, STATIC, DNS, DNS_ROUND_ROBIN.
endpoints
An explicit list of network endpoints. Required when resolution is STATIC. Optional with DNS resolution to provide labels or locality information. Each endpoint can have an address, ports, labels, network, locality, and weight.
exportTo
Controls the visibility of this ServiceEntry across namespaces. Use "." for the current namespace only, "*" for all namespaces. In multi-team clusters, restrict exports to avoid namespace pollution.
Resolution Types: NONE vs STATIC vs DNS vs DNS_ROUND_ROBIN
The resolution field determines how Envoy discovers the IP addresses behind the service. Getting this wrong is the number one cause of ServiceEntry misconfigurations. Here is a clear breakdown.
| Resolution | How It Works | Best For |
|---|---|---|
NONE | Envoy uses the original destination IP from the connection. No DNS lookup by the proxy. | Wildcard entries, pass-through scenarios, services where the application already resolved the IP. |
STATIC | Envoy routes to the IPs listed in the endpoints field. No DNS involved. | Services with stable, known IPs (e.g., on-prem databases, VMs with fixed IPs). |
DNS | Envoy resolves the hostname at connection time and creates an endpoint per returned IP. Uses async DNS with health checking per IP. | External APIs behind load balancers, managed databases with DNS endpoints (RDS, CloudSQL). |
DNS_ROUND_ROBIN | Envoy resolves the hostname and uses a single logical endpoint, rotating across returned IPs. No per-IP health checking. | Simple external services, services where you do not need per-endpoint circuit breaking. |
When to Use NONE
Use NONE when you want to register a range of external IPs or wildcard hosts without Envoy performing any address resolution. This is common for broad egress policies: “allow traffic to *.googleapis.com on port 443.” Envoy will simply forward traffic to whatever IP the application resolved via kube-dns. The downside: Envoy has limited ability to apply per-endpoint policies.
When to Use STATIC
Use STATIC when the external service has known, stable IP addresses that rarely change. This avoids DNS dependencies entirely. You define the IPs in the endpoints list. Classic use case: a legacy Oracle database on a fixed IP in your data center.
When to Use DNS
Use DNS for most external API integrations. Envoy performs asynchronous DNS resolution and creates a cluster endpoint for each returned IP address. This enables per-endpoint health checking and circuit breaking — critical for production reliability. This is the mode you want for services like api.stripe.com or your RDS instance endpoint.
When to Use DNS_ROUND_ROBIN
Use DNS_ROUND_ROBIN when the external hostname returns many IPs and you do not need per-IP circuit breaking. Envoy treats all resolved IPs as a single logical endpoint and round-robins across them. This is lighter weight than DNS mode and avoids creating a large number of endpoints in Envoy’s cluster configuration.
Practical Patterns
Pattern 1: External HTTP API (api.stripe.com)
The most common ServiceEntry pattern. Your application calls a third-party HTTPS API. You want Istio telemetry, and optionally retries and timeouts.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: stripe-api
namespace: payments
spec:
hosts:
- api.stripe.com
location: MESH_EXTERNAL
ports:
- number: 443
name: tls
protocol: TLS
resolution: DNSNote the protocol is TLS, not HTTPS. Since your application initiates the TLS handshake directly, Envoy handles this as opaque TLS using SNI-based routing. If you were terminating TLS at the sidecar and doing TLS origination via a DestinationRule, you would set the protocol to HTTP and handle the upgrade separately — but for most external APIs, let the application manage its own TLS.
Pattern 2: External Managed Database (RDS / CloudSQL)
Managed databases expose a DNS endpoint that resolves to one or more IPs. During failover, the DNS record changes. You need Envoy to respect DNS TTLs and route to the current primary.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: orders-database
namespace: orders
spec:
hosts:
- orders-db.abc123.us-east-1.rds.amazonaws.com
location: MESH_EXTERNAL
ports:
- number: 5432
name: postgres
protocol: TCP
resolution: DNSFor TCP services, Envoy cannot use HTTP headers to route, so it relies on IP-based matching. The DNS resolution mode ensures Envoy periodically re-resolves the hostname and updates its endpoint list. This is critical for RDS multi-AZ failover scenarios where the DNS endpoint flips to a new IP.
Pattern 3: Legacy Internal Service Not in the Mesh
You have a monitoring service running on a set of VMs at known IP addresses inside your VPC. It is not part of the mesh, but your meshed services need to talk to it.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: legacy-monitoring
namespace: observability
spec:
hosts:
- legacy-monitoring.internal
location: MESH_INTERNAL
ports:
- number: 8080
name: http
protocol: HTTP
resolution: STATIC
endpoints:
- address: 10.0.5.10
- address: 10.0.5.11
- address: 10.0.5.12Key differences: location is MESH_INTERNAL because the service lives inside your network, and resolution is STATIC because we know the IPs. The hostname legacy-monitoring.internal is synthetic — your application uses it, and Istio’s DNS proxy (or a CoreDNS entry) resolves it to one of the listed endpoints.
Pattern 4: TCP Services with Multiple Ports
Some external services expose multiple TCP ports — for example, an Elasticsearch cluster with both data (9200) and transport (9300) ports.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: external-elasticsearch
namespace: search
spec:
hosts:
- es.example.com
location: MESH_EXTERNAL
ports:
- number: 9200
name: http
protocol: HTTP
- number: 9300
name: transport
protocol: TCP
resolution: DNSEach port gets its own Envoy listener configuration. The HTTP port benefits from full Layer 7 telemetry and traffic management. The TCP port gets Layer 4 metrics and connection-level policies.
Combining ServiceEntry with DestinationRule
A ServiceEntry alone registers the external service. To apply traffic policies — connection pooling, circuit breaking, TLS origination, load balancing — you pair it with a DestinationRule. This is where things get powerful.
Connection Pooling and Circuit Breaking
External APIs have rate limits. Your managed database has a maximum connection count. Protecting these dependencies at the mesh level prevents cascading failures.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: stripe-api
namespace: payments
spec:
hosts:
- api.stripe.com
location: MESH_EXTERNAL
ports:
- number: 443
name: tls
protocol: TLS
resolution: DNS
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: stripe-api-dr
namespace: payments
spec:
host: api.stripe.com
trafficPolicy:
connectionPool:
tcp:
maxConnections: 50
connectTimeout: 5s
http:
h2UpgradePolicy: DO_NOT_UPGRADE
maxRequestsPerConnection: 100
outlierDetection:
consecutive5xxErrors: 3
interval: 30s
baseEjectionTime: 60s
maxEjectionPercent: 100This configuration caps outbound connections to Stripe at 50, sets a 5-second connection timeout, and ejects endpoints that return 3 consecutive 5xx errors. In production, this prevents a degraded third-party API from consuming all your connection slots and causing a domino effect across your services.
TLS Origination
Sometimes your application speaks plain HTTP, but the external service requires HTTPS. Instead of modifying application code, you can offload TLS origination to the sidecar.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: external-api
namespace: default
spec:
hosts:
- api.external-service.com
location: MESH_EXTERNAL
ports:
- number: 80
name: http
protocol: HTTP
- number: 443
name: https
protocol: TLS
resolution: DNS
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: external-api-tls
namespace: default
spec:
host: api.external-service.com
trafficPolicy:
portLevelSettings:
- port:
number: 443
tls:
mode: SIMPLEYour application sends HTTP to port 80. A VirtualService (shown in the next section) redirects that to port 443. The DestinationRule initiates TLS to the external endpoint. The application never knows TLS happened.
Combining ServiceEntry with VirtualService
VirtualService gives you Layer 7 traffic management for external services: retries, timeouts, fault injection, header-based routing, and traffic shifting. This is invaluable when you are migrating between API providers or need resilience policies for unreliable external dependencies.
Retries and Timeouts
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: stripe-api-vs
namespace: payments
spec:
hosts:
- api.stripe.com
http:
- route:
- destination:
host: api.stripe.com
port:
number: 443
timeout: 10s
retries:
attempts: 3
perTryTimeout: 3s
retryOn: connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes
retryRemoteLocalities: trueThis applies a 10-second overall timeout with up to 3 retry attempts (3 seconds each) for specific failure conditions. Note that this only works for HTTP-protocol ServiceEntries. For TLS-protocol entries where Envoy cannot see the HTTP layer, you are limited to TCP-level connection retries configured via the DestinationRule.
Traffic Shifting Between External Providers
Migrating from one external API to another? Use weighted routing to shift traffic gradually.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: geocoding-primary
namespace: geo
spec:
hosts:
- geocoding.internal
location: MESH_EXTERNAL
ports:
- number: 443
name: tls
protocol: TLS
resolution: STATIC
endpoints:
- address: api.old-geocoding-provider.com
labels:
provider: old
- address: api.new-geocoding-provider.com
labels:
provider: new
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: geocoding-dr
namespace: geo
spec:
host: geocoding.internal
trafficPolicy:
tls:
mode: SIMPLE
subsets:
- name: old-provider
labels:
provider: old
- name: new-provider
labels:
provider: new
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: geocoding-vs
namespace: geo
spec:
hosts:
- geocoding.internal
http:
- route:
- destination:
host: geocoding.internal
subset: old-provider
weight: 80
- destination:
host: geocoding.internal
subset: new-provider
weight: 20This sends 80% of geocoding traffic to the old provider and 20% to the new one. Adjust the weights as you gain confidence. Fully reversible — just set the old provider back to 100%.
DNS Resolution Patterns: Istio DNS Proxy vs kube-dns
Istio DNS resolution for external services involves two layers: how your application resolves the hostname (kube-dns / CoreDNS), and how the sidecar resolves the hostname (Envoy’s async DNS or Istio’s DNS proxy). Understanding the interplay is crucial for reliable Istio DNS behavior.
Default Flow (Without Istio DNS Proxy)
Your application calls api.stripe.com. kube-dns resolves it to an IP. The application opens a connection to that IP. The sidecar intercepts the connection and — if the ServiceEntry uses DNS resolution — Envoy independently resolves api.stripe.com to determine its endpoint list. Two separate DNS lookups happen, which can lead to inconsistencies if DNS records change between the two resolutions.
With Istio DNS Proxy (dns.istio.io)
Istio’s sidecar includes a DNS proxy that intercepts DNS queries from the application. When enabled (via meshConfig.defaultConfig.proxyMetadata.ISTIO_META_DNS_CAPTURE and ISTIO_META_DNS_AUTO_ALLOCATE), the proxy can:
- Auto-allocate virtual IPs for ServiceEntry hosts that do not have addresses defined, which is critical for TCP ServiceEntries that need IP-based matching.
- Resolve ServiceEntry hosts directly, avoiding the round-trip to kube-dns for known mesh services.
- Ensure consistency between the application’s DNS resolution and the sidecar’s endpoint resolution.
In modern Istio installations (1.18+), DNS capture is enabled by default. Verify with:
istioctl proxy-config bootstrap <pod-name> -n <namespace> | grep -A2 "ISTIO_META_DNS"When DNS Proxy Matters Most
The DNS proxy is especially important for TCP ServiceEntries without an explicit addresses field. Without a VIP, Envoy cannot match an incoming TCP connection to the correct ServiceEntry because there is no HTTP Host header to inspect. The DNS proxy solves this by auto-allocating a VIP from the 240.240.0.0/16 range and returning that VIP when the application resolves the hostname. The sidecar then intercepts traffic to that VIP and routes it to the correct external endpoint.
Sticky Sessions with ServiceEntry
Some external services require session affinity — for example, a legacy service that stores session state in memory, or a WebSocket endpoint that must maintain a persistent connection to the same backend. Istio supports sticky sessions for external services through consistent hashing in a DestinationRule.
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
name: legacy-session-service
namespace: default
spec:
hosts:
- legacy-session.internal
location: MESH_INTERNAL
ports:
- number: 8080
name: http
protocol: HTTP
resolution: STATIC
endpoints:
- address: 10.0.1.10
- address: 10.0.1.11
- address: 10.0.1.12
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: legacy-session-dr
namespace: default
spec:
host: legacy-session.internal
trafficPolicy:
loadBalancer:
consistentHash:
httpCookie:
name: SERVERID
ttl: 3600sThis configuration hashes on an HTTP cookie named SERVERID. If the cookie does not exist, Envoy generates one and sets it on the response so that subsequent requests from the same client stick to the same endpoint. You can also hash on:
- HTTP header:
consistentHash.httpHeaderName: "x-user-id"— useful when your application sends a user identifier in every request. - Source IP:
consistentHash.useSourceIp: true— simplest option but breaks in environments with NAT or shared egress IPs. - Query parameter:
consistentHash.httpQueryParameterName: "session_id"— for REST APIs that include a session identifier in the URL.
Sticky sessions with ServiceEntry work identically to in-mesh sticky sessions. The key requirement is that the ServiceEntry must use STATIC or DNS resolution (not NONE) so that Envoy has multiple endpoints to hash across. With DNS_ROUND_ROBIN, there is only one logical endpoint, so consistent hashing has no effect.
Troubleshooting Common Issues
503 Errors When Calling External Services
The most common ServiceEntry issue. Start with this diagnostic sequence:
# Check if the ServiceEntry is applied and visible to the proxy
istioctl proxy-config cluster <pod-name> -n <namespace> | grep <external-host>
# Check the listeners
istioctl proxy-config listener <pod-name> -n <namespace> --port <port>
# Look at Envoy access logs for the specific request
kubectl logs <pod-name> -n <namespace> -c istio-proxy | grep <external-host>Common causes of 503 errors:
- Wrong protocol: Setting
protocol: HTTPSwhen your application initiates TLS. UseTLSfor pass-through; useHTTPonly if the sidecar does TLS origination. - Missing ServiceEntry in REGISTRY_ONLY mode: If
outboundTrafficPolicyisREGISTRY_ONLY, any host without a ServiceEntry is blocked. - exportTo restriction: The ServiceEntry is in namespace A, exported only to
".", and the calling pod is in namespace B. - DNS resolution failure: Envoy cannot resolve the hostname. Check that the DNS servers are reachable from the pod.
DNS Resolution Failures
When Envoy’s async DNS resolver fails, you will see UH (upstream unhealthy) or UF (upstream connection failure) flags in access logs.
# Verify DNS works from inside the sidecar
kubectl exec <pod-name> -n <namespace> -c istio-proxy -- \
pilot-agent request GET /dns_resolve?proxyID=<pod-name>.<namespace>&host=api.stripe.com
# Check Envoy cluster health
istioctl proxy-config endpoint <pod-name> -n <namespace> | grep <external-host>If the endpoint shows UNHEALTHY, Envoy resolved the DNS but the outlier detection ejected the host. If no endpoint appears at all, DNS resolution is failing. Common fix: ensure your pods can reach an external DNS server, or that CoreDNS is configured to forward queries for the external domain.
TLS Origination Not Working
If you configured TLS origination via a DestinationRule but traffic still fails:
- Ensure the ServiceEntry port protocol is
HTTP, notTLS. If you set it toTLS, Envoy treats the connection as opaque TLS pass-through and will not apply the DestinationRule’s TLS settings. - Verify the DestinationRule’s
hostfield exactly matches the ServiceEntry’shostsentry. - Check that the VirtualService (if used) routes to the correct port number.
TCP ServiceEntry Not Intercepting Traffic
For TCP-protocol ServiceEntries without the DNS proxy, Envoy cannot match traffic by hostname. You must either:
- Set an explicit
addressesfield with a VIP that your application targets. - Enable Istio’s DNS proxy to auto-allocate VIPs.
- Ensure the destination IP matches what the ServiceEntry resolves to.
Without one of these, TCP traffic goes through the PassthroughCluster and bypasses your ServiceEntry entirely.
Frequently Asked Questions
Do I need a ServiceEntry if outboundTrafficPolicy is set to ALLOW_ANY?
You do not need one for connectivity — your services can reach external hosts without it. But you should create ServiceEntries anyway. Without them, outbound traffic goes through the PassthroughCluster, which means no detailed metrics per destination, no access logging with the external hostname, no circuit breaking, no retries, and no timeout policies. A ServiceEntry is the difference between “it works” and “it works reliably with observability.”
What is the difference between protocol TLS and HTTPS in a ServiceEntry port?
TLS tells Envoy to treat the connection as opaque TLS. Envoy reads the SNI header to determine routing but does not decrypt the payload. Use this when your application initiates TLS directly. HTTPS tells Envoy the protocol is HTTP over TLS, which implies Envoy should handle TLS. In practice, for external services where the application manages its own TLS, use TLS. Use HTTP with a DestinationRule TLS origination when you want the sidecar to handle TLS.
Can I use wildcards in ServiceEntry hosts?
Yes, but with limitations. You can use *.example.com to match any subdomain of example.com. However, wildcard entries only work with resolution: NONE because Envoy cannot perform DNS lookups for wildcard hostnames. This means you lose the ability to apply per-endpoint traffic policies. Wildcard ServiceEntries are best used for broad egress access control rather than fine-grained traffic management.
How do I configure sticky sessions for an external service behind a ServiceEntry?
Create a ServiceEntry with STATIC or DNS resolution (so Envoy has multiple endpoints), then pair it with a DestinationRule that configures consistentHash under trafficPolicy.loadBalancer. You can hash on an HTTP cookie, header, source IP, or query parameter. The ServiceEntry must expose multiple endpoints for consistent hashing to have any effect. See the “Sticky Sessions with ServiceEntry” section above for a complete YAML example.
How does ServiceEntry interact with NetworkPolicy and Istio AuthorizationPolicy?
A ServiceEntry does not bypass Kubernetes NetworkPolicy. If a NetworkPolicy blocks egress to the external IP, traffic will be dropped at the CNI level before Envoy can route it. Istio AuthorizationPolicy can also restrict which workloads are allowed to call specific ServiceEntry hosts. For defense in depth, use ServiceEntry for traffic management and observability, AuthorizationPolicy for workload-level access control, and NetworkPolicy for network-level enforcement.
Wrapping Up
ServiceEntry is one of the most practical Istio resources you will use in production. It transforms opaque outbound connections into managed, observable, policy-controlled traffic — and it does so without requiring changes to your application code. Start with the basics: create a ServiceEntry for each external dependency, set the correct resolution type, and pair it with a DestinationRule for connection limits and circuit breaking. As you mature, add VirtualServices for retries and timeouts, configure sticky sessions where needed, and enable the DNS proxy for seamless TCP service integration.
The pattern is always the same: register the service, apply policies, observe the traffic. Every external dependency you formalize with a ServiceEntry is one fewer blind spot in your production mesh.