HTTP Example

In this example, we will deploy a simple HTTP service and expose it to the Cilium Gateway API.

The demo application is from the bookinfo demo microservices app from the Istio project.

Deploy the Demo App

$ kubectl apply -f

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.

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


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

Deploy the Cilium Gateway

You’ll find the example Gateway and HTTPRoute definition in basic-http.yaml.

kind: Gateway
  name: my-gateway
  gatewayClassName: cilium
  - protocol: HTTP
    port: 80
    name: web-gw
        from: Same
kind: HTTPRoute
  name: http-app-1
  - name: my-gateway
    namespace: default
  - matches:
    - path:
        type: PathPrefix
        value: /details
    - name: details
      port: 9080
  - matches:
    - headers:
      - type: Exact
        name: magic
        value: foo
      - type: Exact
        name: great
        value: example
        type: PathPrefix
        value: /
      method: GET
    - name: productpage
      port: 9080
$ kubectl apply -f

The above example creates a Gateway named my-gateway that listens on port 80. Two routes are defined, one for /details to the details service, and one for / to the productpage service.

Your cloud provider will automatically provision an external IP address for the gateway, but it may take up to 20 minutes.

$ kubectl get gateway my-gateway
NAME         CLASS    ADDRESS        READY   AGE
my-gateway   cilium   True    2d7h


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

Make HTTP Requests

Now that the Gateway is ready, you can make HTTP requests to the services.

$ GATEWAY=$(kubectl get gateway my-gateway -o jsonpath='{.status.addresses[0].value}')
$ curl --fail -s http://"$GATEWAY"/details/1 | jq
  "id": 1,
  "author": "William Shakespeare",
  "year": 1595,
  "type": "paperback",
  "pages": 200,
  "publisher": "PublisherA",
  "language": "English",
  "ISBN-10": "1234567890",
  "ISBN-13": "123-1234567890"
$ curl -v -H 'magic: foo' http://"$GATEWAY"\?great\=example
<!DOCTYPE html>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css">


    <h3>Hello! This is a simple bookstore application consisting of three services as shown below</h3>

<table class="table table-condensed table-bordered table-hover"><tr><th>name</th><td>http://details:9080</td></tr><tr><th>endpoint</th><td>details</td></tr><tr><th>children</th><td><table class="table table-condensed table-bordered table-hover"><tr><th>name</th><th>endpoint</th><th>children</th></tr><tr><td>http://details:9080</td><td>details</td><td></td></tr><tr><td>http://reviews:9080</td><td>reviews</td><td><table class="table table-condensed table-bordered table-hover"><tr><th>name</th><th>endpoint</th><th>children</th></tr><tr><td>http://ratings:9080</td><td>ratings</td><td></td></tr></table></td></tr></table></td></tr></table>

    <h4>Click on one of the links below to auto generate a request to the backend as a real user or a tester
<p><a href="/productpage?u=normal">Normal user</a></p>
<p><a href="/productpage?u=test">Test user</a></p>

<!-- Latest compiled and minified JavaScript -->
<script src="static/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="static/bootstrap/js/bootstrap.min.js"></script>