istio traffic mirroring lab and sample

 

Istio support traffic mirroring and the configuration can be added in the virtual service itself.

    mirror:
      host: httpbin
      subset: v2
    mirrorPercentage:
      value: 100.0

In this example, I am using httpbin to demonstrate traffic mirroring. 

1. Deploy httpbin v1 and v2 - So i have 2 pods running httpbin with different labels. 

2. Setup gateway, virtual service and destination rules. The destination rule supports subsets. 

3. Then turn on mirroring on the virtual service. 


Steps 

Deploy 2 different version of httpbin - v1 and v2 by running the following command:-


kubectl apply -f .\httpbin.yaml -n test

kubectl apply -f .\httpbin-v2.yaml -n test


Deploy the httpbin-gateway 

kubectl apply .\httpbin-gateway.yaml -n test

Run a few curl http://localhost At this point you can check to see the logs for your pods.

kubectl logs your-v1-pod-name -n test

There should be output and no output/request going into podv2

Turning on mirroring

kubectl apply .\httpbin-gateway-v2.yaml -n test

kubectl logs your-v1-pod-name -n test kubectl logs your-v2-pod-name -n test

Check to ensure that logs is coming out for both pods.


The sample code can be found here

https://github.com/mitzenjeremywoo/istio-mirroring-example


Can traffic routing happens without setting up destination rule subset?

You must setup deistination rule subset that matches the virtual service traffic mirroring subset definitions:-

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "*"
  gateways:
  - httpbin-gateway
  http:
  - route:
    - destination:
        host: httpbin
        subset: v1
        port:
          number: 8000
      weight: 100
    mirror:
      host: httpbin
      subset: v2
    mirrorPercentage:
      value: 100.0

     

 

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: httpbin
spec:
  host: httpbin
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2


Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm