Not Able to configure session Affinity via istio-ingress

12/20/2018

I have a requirement to configure stickiness, with istio-ingress and following documentation, I have defined my gateway, virtual service and destination rules like below

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: app-http-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - app.k8istio.test.example.com
    - app
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: app
spec:
  hosts:
  - app.k8istio.test.example.com
  gateways:
  - app-http-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: app
        port:
          number: 8080
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: app-dr
spec:
  host: app
  trafficPolicy:
    loadBalancer:
      consistentHash:
        httpCookie:
          name: testcookie
          ttl: 0s

However, my request does not stick to one pod behind the service app instead it is still getting routed to both pods behind the service app in round robin.

Also, I expected that I will get testcookie in response header, which will be used further via client-browser to go back to the same pod however it is not happening I have also tried setting httpCookie as JSESSIONID but it did not work.

istioctl version Version: 1.0.4

How could I achieve session sickness with istio-ingress ?

-- Ruchir Bharadwaj
istio
kubernetes

1 Answer

12/21/2018

The config was correct, the issue was because of silly mistake of deploying istio-gateway in default namespace then that of the service app

-- Ruchir Bharadwaj
Source: StackOverflow