Ingress HTTP Example

The example ingress configuration routes traffic to backend services from the bookinfo demo microservices app from the Istio project.

Deploy the Demo App

  1. $ kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.11/samples/bookinfo/platform/kube/bookinfo.yaml

This is just deploying the demo app, it’s not adding any Istio components. You can confirm that with Cilium Service Mesh there is no Envoy sidecar created alongside each of the demo app microservices.

  1. $ kubectl get pods
  2. NAME READY STATUS RESTARTS AGE
  3. details-v1-5498c86cf5-kjzkj 1/1 Running 0 2m39s
  4. productpage-v1-65b75f6885-ff59g 1/1 Running 0 2m39s
  5. ratings-v1-b477cf6cf-kv7bh 1/1 Running 0 2m39s
  6. reviews-v1-79d546878f-r5bjz 1/1 Running 0 2m39s
  7. reviews-v2-548c57f459-pld2f 1/1 Running 0 2m39s
  8. reviews-v3-6dd79655b9-nhrnh 1/1 Running 0 2m39s

Note

With the sidecar implementation the output would show 2/2 READY. One for the microservice and one for the Envoy sidecar.

Deploy the First Ingress

You’ll find the example Ingress definition in basic-ingress.yaml.

  1. $ kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/v1.12/examples/kubernetes/servicemesh/basic-ingress.yaml

This example routes requests for the path /details to the details service, and / to the productpage service.

Getting the list of services, you’ll see a LoadBalancer service is automatically created for this ingress. Your cloud provider will automatically provision an external IP address, but it may take around 30 seconds.

  1. $ kubectl get svc
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. cilium-ingress-basic-ingress LoadBalancer 10.98.169.125 10.98.169.125 80:32478/TCP 2m11s
  4. details ClusterIP 10.102.131.226 <none> 9080/TCP 2m15s
  5. kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10m
  6. productpage ClusterIP 10.97.231.139 <none> 9080/TCP 2m15s
  7. ratings ClusterIP 10.108.152.42 <none> 9080/TCP 2m15s
  8. reviews ClusterIP 10.111.145.160 <none> 9080/TCP 2m15s

The external IP address should also be populated into the Ingress:

  1. $ kubectl get ingress
  2. NAME CLASS HOSTS ADDRESS PORTS AGE
  3. basic-ingress cilium * 10.98.169.125 80 97s

Note

Some providers e.g. EKS use a fully-qualified domain name rather than an IP address.

Make HTTP Requests

Check (with curl or in your browser) that you can make HTTP requests to that external address. The / path takes you to the home page for the bookinfo application.

From outside the cluster you can also make requests directly to the details service using the path /details. But you can’t directly access other URL paths that weren’t defined in basic-ingress.yaml.

For example, you can get JSON data from a request to <address>/details/1 and get back some data, but you will get a 404 error if you make a request to <address>/ratings.

  1. $ HTTP_INGRESS=$(kubectl get ingress basic-ingress -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  2. $ curl --fail -s http://"$HTTP_INGRESS"/details/1 | jq
  3. {
  4. "id": 1,
  5. "author": "William Shakespeare",
  6. "year": 1595,
  7. "type": "paperback",
  8. "pages": 200,
  9. "publisher": "PublisherA",
  10. "language": "English",
  11. "ISBN-10": "1234567890",
  12. "ISBN-13": "123-1234567890"
  13. }