As I move from Docker to Kubernetes, I am moving to use Traefik 2.1 for my ingress. I need sticky sessions to support some of my applications.

If you've tried looking through the documentation and searching the internet, there's not much on the latest version of Traefik. Currently that's 2.1. There's even less on the official documentation about using Kubernetes. Then even less on configuring sticky sessions. Which is really, really sad. Especially for a load balancer application where sticky sessions is a basic function. Anyways, that's my rant so far. Now to how to solve the problem.

Digging through the source code I found a sticky.cookie element you can add to your route. There are 3 options:

Name Purpose
httpOnly Adds the HttpOnly flag to the cookie
name Sets the name of the cookie
secure Makes the cookie only apply to https requests

Now, I bet you're wondering where to put that. It goes on your IngressRoute in the route service. Here's a full example that uses a cookie named pester to store the sticky data:

kind: IngressRoute
  name: myingressroute
  namespace: default

    - web

  - match: PathPrefix(`/whoami`)
    kind: Rule
    - name: whoami
      port: 80
          httpOnly: true
          name: pester

Currently, it stores the IP address and port of the container connecting to. Which is sad. It would be nice to see them use a UUID or something unique instead or at least make that a configurable option. Security guys don't seem to like IP's being disclosed to the public.

If you want to go dumpster diving through the code to figure out anything else about sticky sessions, the file that it's stored in is at

I hope this helps someone, because it sure would have been nice to have a plain, simple, basic example.