The components deployed on the service mesh by default are not exposed outside the cluster. External access to individual services so far has been provided by creating an external load balancer on each service.
A Kubernetes Ingress rule can be created that routes external requests through the Istio Ingress controller to the backing services.
-
Configure the guestbook UI default route with the Istio Ingress controller.
kubectl apply -f guestbook/guestbook-ingress.yaml
-
Review the YAML file for your Ingress controller. In this file, the Ingress class is specified as
kubernetes.io/ingress.class: istio
, which routes every request to the Istio Ingress controller. When you look at the Ingress rules that are defined in this YAML, you see that requests are routed to either thehelloworld-service
orguestbook-ui
service, depending on the URL path that is used in the request.kubectl describe ingress Name: simple-ingress Namespace: default Address: Default backend: default-http-backend:80 (<none>) Rules: Host Path Backends ---- ---- -------- * /hello/.* helloworld-service:8080 (<none>) /.* guestbook-ui:80 (<none>) Annotations: Events: <none>
-
Get the
External-IP
of the Istio Ingress controller.kubectl get service istio-ingress -n istio-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-ingress 10.31.244.185 169.47.103.138 80:31920/TCP,443:32165/TCP 1h
-
Store the external IP address from the previous command as a session variable.
export INGRESS_IP=[external_IP]
-
Use the external IP address to access the guestbook UI in your web browser.
http://[external_IP]
-
Access the Hello World service and see the response JSON in your web browser.
http://[external_IP]/hello/world
-
Curl the guestbook service.
curl http://$INGRESS_IP/echo/universe
-
Curl the helloworld service:
curl http://$INGRESS_IP/hello/world
-
Curl the guestbook service multiple times. Every request that you send to your guestbook service is load balanced between the two hello world service instances (
v1
andv2
) on a round robin basis. You can see the different hello world service versions in thehostname
andgreeting
field of your CLI output.curl http://$INGRESS_IP/echo/universe {"greeting":{"hostname":"helloworld-service-v1-286408581-9204h","greeting":"Hello universe from helloworld-service-v1-286408581-9204h with 1.0","version":"1.0"},
curl http://$INGRESS_IP/echo/universe {"greeting":{"hostname":"helloworld-service-v2-1009285752-n2tpb","greeting":"Hello universe from helloworld-service-v2-1009285752-n2tpb with 2.0","version":"2.0"}