Istio Multicluster Traffic Split

Hello, In Istio Multi-Primary setup, if you have the same app deployed in both the clusters [with same service name & same no: of replicas] traffic from cluster1 get’s equally distributed to pods in both the clusters. Is there a way to specify a weight for the traffic split across clusters, so that instead of 50:50 split I can specify x% of traffic from the cluster1 needs to be routed to cluster2 pods & vice versa?

1 Like

Hi, I had the same problem as you. I try to split the traffic by using the weight parameters on the virtual service manifest but it doesn’t work. Because the istio is doesn’t recognize the workload label on the second cluster.

Hi @bagas_awibowo
I had received a response from @hzxuzhonghu in Istio slack channel on the same.
This option is possible with the following patch

However this option will be available in Istio version 1.11.2 only.

Should be 1.11.1 as it have been in release-1.11 branch now

在 2021-08-24 18:59:03,“Soji Antony via Discuss Istio” istio@discoursemail.com 写道:

@hzxuzhonghu I have installed 1.11.1 in multi-primary mode, but not seeing a label ‘topology.istio.io/cluster’ label getting added in Pods. Is this feature available in 1.11.1?

It is not injected to the pod by sidecar-injector. It is internally in istio.

Hi @hzxuzhonghu I am having some trouble to get this working. Listing down the steps below which I followed for better clarity.

  1. Created multiprimary setup following Istio / Install Multi-Primary
> $ cat cluster1.yaml
> apiVersion: install.istio.io/v1alpha1
> kind: IstioOperator
> metadata:
>   namespace: istio-system
>   name: cluster1-istiocontrolplane
> spec:
>   profile: default
>   values:
>     global:
>       meshID: mesh1
>       multiCluster:
>         clusterName: cluster1
>       network: network1
> $ cat cluster2.yaml
> apiVersion: install.istio.io/v1alpha1
> kind: IstioOperator
> metadata:
>   namespace: istio-system
>   name: cluster2-istiocontrolplane
> spec:
>   profile: default
>   values:
>     global:
>       meshID: mesh1
>       multiCluster:
>         clusterName: cluster2
>       network: network1
  1. I have a test application v1 running in cluster1 & v2 running in cluster2 under ‘sample’ namespace [svc: testapp.sample.svc.cluster.local]
  2. Created a DestinationRule
$ cat destinationrule.yaml
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: testapp
spec:
  host: testapp
  trafficPolicy:
    loadBalancer:
      simple: LEAST_CONN
  subsets:
  - name: network1
    labels:
      topology.istio.io/cluster: cluster1
  - name: kubernetes
    labels:
      topology.istio.io/cluster: cluster2
  1. Created a VirtualService with traffic split
$ cat virtualservice.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: testapp
spec:
  hosts:
    - testapp.sample.svc.cluster.local
  http:
  - route:
    - destination:
        host: testapp.sample.svc.cluster.local
        subset: network1
      weight: 100
    - destination:
        host: testapp.sample.svc.cluster.local
        subset: network2
      weight: 0

My assumption was now all the traffic will go to cluster1 Pods. But this doesn’t seems to be working. Is this the correct method or am I missing something?
Thanks

Hello, I’d really appreciate it if someone could shed some light upon this problem.