The following example creates an HTTP virtual gateway listener and route table for your sample apps on the www.example.com host. You can use this setup to test most Gloo policies, such as traffic management, security, and resiliency policies.

Set up routing

  1. Create a VirtualGateway resource to configure an HTTP listener on your ingress gateway proxy, which starts a process that continuously listens for incoming client requests for a specific host, port, and protocol.

      kubectl apply -f- <<EOF
    apiVersion: networking.gloo.solo.io/v2
    kind: VirtualGateway
    metadata:
      name: istio-ingressgateway
      namespace: bookinfo
    spec:
      listeners:
      - http: {}
        port:
          number: 80
      workloads:
      - selector:
          labels:
            istio: ingressgateway
    EOF
      
  2. Set up a route table to forward incoming requests to the services of the Bookinfo and httpbin apps that you exposed with the HTTP gateway.

      kubectl apply -f- <<EOF
    apiVersion: networking.gloo.solo.io/v2
    kind: RouteTable
    metadata:
      name: www-example-com
      namespace: bookinfo
    spec:
      hosts:
        - www.example.com
      # Selects the virtual gateway you previously created
      virtualGateways:
        - name: istio-ingressgateway
          namespace: bookinfo
      http:
        # Route for the main productpage app
        - name: productpage
          matchers:
          - uri:
              prefix: /productpage
          forwardTo:
            destinations:
              - ref:
                  name: productpage
                  namespace: bookinfo
                port:
                  number: 9080
        # Routes all /reviews requests to the reviews-v1 or reviews-v2 apps
        - name: reviews
          labels: 
            route: reviews
          matchers:
          - uri:
              prefix: /reviews
          forwardTo:
            destinations:
              - ref:
                  name: reviews
                  namespace: bookinfo
                port:
                  number: 9080
        # Routes all /ratings requests to the ratings-v1 app
        - name: ratings-ingress
          labels:
            route: ratings
          matchers:
          - uri:
              prefix: /ratings
          forwardTo:
            destinations:
              - ref:
                  name: ratings
                  namespace: bookinfo
                port:
                  number: 9080
        # Route for the httpbin app
        - name: httpbin-ingress
          labels:
            route: httpbin
          matchers:
          - headers:
            - name: X-httpbin
          forwardTo:
            destinations:
              - ref:
                  name: httpbin
                  namespace: httpbin
                port:
                  number: 8000
    
    EOF
      
  3. Save the external address of the ingress gateway.

      export INGRESS_GW_ADDRESS=$(kubectl get svc -n gloo-mesh-gateways istio-ingressgateway -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}")
    echo $INGRESS_GW_ADDRESS
      
  4. Send a request to each route to verify that you can reach the apps’ services. If not, try Debugging your route.

    • productpage:
        curl -vik http://www.example.com:80/productpage --resolve www.example.com:80:$INGRESS_GW_ADDRESS
        
      Example output:
        HTTP/2 200 
      ...
        
    • ratings:
        curl -vik http://www.example.com:80/ratings/1 --resolve www.example.com:80:$INGRESS_GW_ADDRESS
        
      Example output:
        HTTP/2 200
      ...
      {"id":1,"ratings":{"Reviewer1":5,"Reviewer2":4}}
        
    • reviews:
        curl -vik http://www.example.com:80/reviews/1 --resolve www.example.com:80:$INGRESS_GW_ADDRESS
      curl -vik http://www.example.com:80/reviews/2 --resolve www.example.com:80:$INGRESS_GW_ADDRESS
        
      Example output:
        HTTP/2 200 
      ...
      {"id": "1","podname": "reviews-v1-55b668fc65-6pc2c","clustername": "null","reviews": [{  "reviewer": "Reviewer1",  "text": "An extremely entertaining play by Shakespeare. The slapstick humour is refreshing!"},{  "reviewer": "Reviewer2",  "text": "Absolutely fun and entertaining. The play lacks thematic depth when compared to other plays by Shakespeare."}]}
        
    • httpbin:
        curl -vik http://www.example.com:80/status/200 -H "X-httpbin: true" --resolve www.example.com:80:$INGRESS_GW_ADDRESS
        
      Example output:
        HTTP/2 200
        

Next

Apply a fault injection policy to the reviews service to delay requests and simulate network issues or an overloaded service.