Using Istio

In this guide, we will create ServiceEntry for our external HyperTest logger service and mirror traffic to it using Istio.

Brief Steps:

  1. Create a new Service Entry for HyperTest logger

  2. Add route rule in Virtual Service to mirror traffic to it

1. Create Service Entry

Here we are creating a new Service Entry for Hypertest. The hosts can be anything here as we have used resolution as STATIC so it will use endpoint address.

hypertest-service-entry.yml
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: hypertest-logger-svc-entry
spec:
  hosts:
    - hypertest.<name_of_your_service>.logger # this can be any value,it is used as a ref later
  location: MESH_EXTERNAL
  ports:
    - number: <hypertest-logger-port> 
      name: http
      protocol: HTTP
  resolution: STATIC
  endpoints:
  - address: <hypertest-vm-ip> 

Create the ServiceEntry using the below command:

kubectl apply -f hypertest-service-entry.yml

2. Add Mirror section to Virtual Service

Now we will add mirror route rule in application's virtual service and point it to host defined in service entry.

Only copy the parts from ## copy from this till ## to this. Rest is just sample Virtual Service file.

service-virtual-service.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: node-app
spec:
  hosts:
  - "*"
  gateways:
  - node-app-gateway
  http:
  - route:
    - destination:
        host: node-app
        port:
          number: <your-application-port>
    ## copy from this 
    mirror:
      host: hypertest.<name_of_your_service>.logger
    ## to this

Update your application's Virtual Service by the follwoing command:

kubectl apply -f service-virtual-service.yaml

To Verify the mirroring setup, hit any api on the application and check for request in "last mirrored requests" section or Session page in HyperTest.

Last updated