This guide shows how to bring an external workload into an Istio service mesh using a ServiceEntry and a VirtualService — without changing the mesh-wide outbound policy. This pattern is useful when the external workload is outside the Kubernetes cluster (for example, an internal EC2 instance or an on-premises web server) and you want Istio to capture and control traffic to it. What you will learn:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- Confirm the cluster and Istio environment
- Create a ServiceEntry for an external host
- Create a VirtualService to instruct Istio how to route traffic to that ServiceEntry
- Ensure the client pod has an Envoy sidecar so Istio can intercept outbound traffic
Prerequisites
| Requirement | Purpose / Example |
|---|---|
| Istio installed | istioctl version (example 1.26.3) |
| External NGINX web app | Reachable at myapp.com (resolved via /etc/hosts to a static IP) |
| kubectl access | To create resources and run test pods |
istioctl version output:
/etc/hosts override):
192.168.121.2 below with the IP address your myapp.com resolves to.
Step 1 — Create a ServiceEntry
A ServiceEntry tells Istio about services that exist outside the mesh. For a fixed IP endpoint useresolution: STATIC. Create a file named se.yaml:
myapp.com:80 to the mesh and instructs Istio to resolve myapp.com to the static IP 192.168.121.2.
Step 2 — Run a test client pod and try curling the external host
Start a simple pod that includes curl. The official nginx image may not include curl; use an image such ascurlimages/curl and keep the pod alive with sleep:
Response Header
Make sure the client pod has an Envoy sidecar injected. If the pod is in a namespace without Istio injection enabled, Istio features (VirtualService routing and ServiceEntry handling through the proxy) will not be applied to that pod’s outbound traffic.
Step 3 — Create a VirtualService to route traffic to the ServiceEntry
A VirtualService tells Istio how to route requests for specified hosts. Createvs.yaml:
myapp.com to myapp.com:80 (redundant looking), it is important: it instructs Istio how to process and forward requests for myapp.com. The destination host myapp.com is then resolved by the ServiceEntry to the external IP.
Step 4 — Ensure the client pod has an Istio sidecar
If the test pod was created in a namespace without sidecar injection, Istio will analyze and warn:default namespace):
READY 2/2:
2/2 indicates the application container plus the Envoy sidecar are running.
Step 5 — Retry the curl from the injected pod
With the Envoy sidecar present, Istio will capture and route outbound traffic according to the ServiceEntry and VirtualService. Run:Troubleshooting & Tips
- If the external service listens on a different port (e.g.,
9090), update the ServiceEntryportsandendpointsaccordingly. - For DNS-resolvable external services use
resolution: DNSand omitendpoints— Istio will resolve the host dynamically. - For fixed internal IPs (such as an on-premise box),
resolution: STATICwithendpointsis appropriate. - If you prefer manual sidecar injection, use
istioctl kube-injector thesidecar.istio.io/injectannotation on pod spec rather than enabling namespace-wide automatic injection. - Use
istioctl analyzeto check for common configuration issues and hints. - Remember to replace the demo IP
192.168.121.2with the correct IP for your environment.
Quick reference commands
| Action | Command |
|---|---|
| Apply ServiceEntry | kubectl apply -f se.yaml |
| Apply VirtualService | kubectl apply -f vs.yaml |
| Run test pod | kubectl run test --image=curlimages/curl --restart=Never --command -- sleep 3600 |
| Exec into pod and curl | kubectl exec test -- curl -sS myapp.com |
| Enable namespace injection | kubectl label namespace default istio-injection=enabled --overwrite |
| Analyze Istio config | istioctl analyze |
Links and References
- Istio Networking Concepts: ServiceEntry — https://istio.io/latest/docs/reference/config/networking/service-entry/
- Istio VirtualService docs — https://istio.io/latest/docs/reference/config/networking/virtual-service/
- Kubernetes Documentation — https://kubernetes.io/docs/