What you’ll accomplish
- Register an external host (myapp.com) and a static endpoint with a ServiceEntry.
- Configure a VirtualService so the mesh routes HTTP traffic to that external endpoint.
- Verify traffic is intercepted by the Istio sidecar and routed correctly.
Prerequisites / quick checks
- Istio is already installed and running.
- An external NGINX server is reachable at
myapp.com. In this lab environment this hostname is mapped to a local IP via/etc/hosts.
/etc/hosts mapping:
Why use a ServiceEntry?
A ServiceEntry tells Istio how to resolve and route traffic for hosts that are outside the mesh. UseMESH_EXTERNAL for workloads outside the cluster and resolution: STATIC when you want to bind a fixed IP endpoint to a hostname.
We use
MESH_EXTERNAL because the workload is outside the mesh. Use resolution: STATIC for fixed IPs; use resolution: DNS for externally resolved hostnames.1) Create a ServiceEntry
Create a file namedse.yaml. Replace the address value with the IP you observed from /etc/hosts.
2) Run a test pod and try to curl
Start a simple test pod. Thenginx image often includes curl; if not, use a curl-specific image (e.g., curlimages/curl).
302 Found). This indicates the ServiceEntry is present but Istio is not yet performing HTTP routing for the host — a VirtualService is required.
3) Create a VirtualService
Createvs.yaml to capture HTTP traffic for myapp.com and forward it to the destination that matches the ServiceEntry.
4) Re-test from the test pod
Try curling again from thetest pod:
5) Enable automatic sidecar injection and recreate the test pod
Label the namespace for injection so new pods receive the Envoy sidecar. Then recreate the test pod.test pod should now show 2/2 (application container + sidecar):
Final curl — success
From the injectedtest pod, curl the external host again:
Summary / Key takeaways
- ServiceEntry registers external hosts and endpoints with the mesh.
- VirtualService captures and routes HTTP traffic for hosts — including external hosts defined by ServiceEntry.
- Pods must have the Istio sidecar (injected) for the mesh to intercept and route their traffic.
- Label namespaces for automatic injection before creating pods that need to be part of the mesh.