I have deployed Traefik v3.6.6 using Helm Chart v38.0.2 to Azure Kubernetes Cluster. HTTPRoute works fine but the moment sticky session is added to the Traefik Service, pods handle request in Round robin fashion and donot adhere to stickyness.
Below is the manifest file used:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: myapp-httproute
spec:
parentRefs:
- name: traefik-gateway
namespace: "myns"
hostnames:
- myapp.test.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /
backendRefs:
- group: traefik.io
kind: TraefikService
name: myapp-sticky-session
---
apiVersion: traefik.io/v1alpha1
kind: TraefikService
metadata:
name: myapp-sticky-session
spec:
weighted:
services:
- name: myapp
port: 80
serversTransport: myapp-server-transport
sticky:
cookie:
name: my_cookie
maxAge: 360
sameSite: none
secure: true
httpOnly: false
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: myapp-server-transport
spec:
forwardingTimeouts:
dialTimeout: 3600s
responseHeaderTimeout: 3600s
idleConnTimeout: 1800s
---
I’ve tried multiple combinations
- serversTransport is removed - did not work.
- URLRewrite is removed - did not work.
- sticky.cookie.httpOnly and sticky.cookie.secure is toggled - did not work.
- Keeping only sticky.cookie.name - did not work.
First attempt to the service includes Cookie in the response header and for consecutive attempts Request Header has Cookie included. But sticky-ness is not maintained.
Traefik logs gives no errors. Although application works, the request is handled by different pods which breaks the overall flow.
