<p>I'd like to implement a sticky-session Ingress controller. Cookies or IP hashing would both be fine; I'm happy as long as the same client is <em>generally</em> routed to the same pod.</p>

<p>What I'm stuck on: it seems like the Kubernetes service model means my connections are going to be proxied randomly no matter what. I can configure my Ingress controller with session affinity, but as soon as the the connection gets past the that and hits a service, <code>kube-proxy</code> is just going to route me randomly. There's the <code>sessionAffinity: ClientIP</code> flag on services, but that doesn't help me -- the Client IP will always be the internal IP of the Ingress pod.</p>

<p>Am I missing something? Is this possible given Kubernetes' current architecture?</p>

<p>I evaluated the haproxy controller but could not get it running reliably with session affinity. After some research I discovered <a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx" rel="nofollow noreferrer" title="Nginx Ingress Controller">Nginx Ingress Controller</a> which since version 0.61 also includes the <em>nginx-sticky-module-ng</em> module and is now running reliably since a couple of days in our test environment. I created a <a href="https://gist.github.com/tillkuhn/c2dba43d60d3e7a2462928812ca9e4bf" rel="nofollow noreferrer">Gist</a> that sets up the required Kubernetes pieces since some important configuration is a bit hard to locate in the existing documentation. Good luck!</p>
