Istio Load balancing to multiple namespaces

12/27/2018

I have two namespaces hosting different versions of my services, namespace sh-blue hosts one version of each service and sh-green hosts new version of each service. With each new deploy all services are updated to new version. I want to implement canary deployment from current version to new version.

The code below is what I currently have and it's working fine, except it's not obvious what kind of load balancing it is using. When I check ingress-gateway logs it's something like: blue, green, green, blue, green, green, green, red, green, blue, blue, blue, green, green, ...

Is it possible to control the load balancing? And is there a better way to setup this?

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: sh-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*.something.local"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sh
spec:
  hosts:
  - "*"
  gateways:
  - sh-gateway
  http:
  - match:
    - uri:
        prefix: /index
    route:
    - destination:
        host: index.sh-blue.svc.cluster.local
        port:
          number: 8080
      weight: 50
    - destination:
        host: index.sh-green.svc.cluster.local
        port:
          number: 8080
      weight: 50
  - match:
    - uri:
        prefix: /config
    route:
    - destination:
        host: config.sh-blue.svc.cluster.local
        port:
          number: 8080
      weight: 50
    - destination:
        host: config.sh-green.svc.cluster.local
        port:
          number: 8080
      weight: 50
-- Rok
istio
kubernetes

1 Answer

12/27/2018

You can specify load balancing configuration within Istio DestinationRule traffic management resource . It requires trafficPolicy to be included for the mesh service in order to control load balancing policy.

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: bookinfo-ratings-port
spec:
  host: ratings.prod.svc.cluster.local
  trafficPolicy: # Apply to all ports
    portLevelSettings:
    - port:
        number: 80
      loadBalancer:
        simple: LEAST_CONN
    - port:
        number: 9080
      loadBalancer:
        simple: ROUND_ROBIN

For more information I do suggest to visit Istio Load Balancer settings overview.

-- mk_sta
Source: StackOverflow