<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>An ingress controller can completely bypass kube-proxy. The haproxy controller for example, <a href="https://github.com/kubernetes/contrib/blob/master/service-loadbalancer/service_loadbalancer.go#L155" rel="nofollow">does this and goes straight to endpoints</a>. However it <a href="https://github.com/kubernetes/contrib/pull/223" rel="nofollow">doesn't use the Ingress in the typical sense</a>. </p>

<p>You could <a href="https://github.com/kubernetes/contrib/blob/master/Ingress/controllers/README.md" rel="nofollow">do the same with the nginx controller</a>, all you need to lookup endpoints and insert them instead of the DNS name it currently uses (i.e swap <a href="https://github.com/kubernetes/contrib/blob/master/Ingress/controllers/nginx-alpha/controller.go#L52" rel="nofollow">this line</a> for a pointer to an upstream that contains the endpoints).</p>
