<p>I had sticky session working in my dev environment with minibike with following configurations:</p>

<p>Ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: gl-ingress
  annotations:
    nginx.ingress.kubernetes.io/affinity: cookie
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.global-static-ip-name: "projects/oceanic-isotope-199421/global/addresses/web-static-ip"
spec:
  backend:
    serviceName: gl-ui-service
    servicePort: 80
  rules:
  - http:
      paths:
      - path: /api/*
        backend:
          serviceName: gl-api-service
          servicePort: 8080
</code></pre>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: gl-api-service
  labels:
    app: gl-api
  annotations:
    ingress.kubernetes.io/affinity: 'cookie'
spec:
  type: NodePort
  ports:
  - port: 8080
    protocol: TCP
  selector:
    app: gl-api
</code></pre>

<p>Now that I have deployed my project to GKE sticky session no longer function. I believe the reason is that the Global Load Balancer configured in GKE does not have session affinity with the NGINX Ingress controller. Anyone have any luck wiring this up? Any help would be appreciated. I wanting to establish session affinity: Client Browser > Load Balancer > Ingress > Service. The actual session lives in the pods behind the service. Its an API Gateway (built with Zuul).</p>

<p><strong>Good news!</strong> Finally they have support for these kind of tweaks as beta features!</p>

<p>Beginning with GKE version 1.11.3-gke.18, you can use an Ingress to configure these properties of a backend service:</p>

<ul>
<li>Timeout</li>
<li>Connection draining timeout</li>
<li>Session affinity</li>
</ul>

<p>The configuration information for a backend service is held in a custom resource named BackendConfig, that you can "attach" to a Kubernetes Service.</p>

<p>Together with other sweet beta-features (like CDN, Armor, etc...) you can find how-to guides here:
<a href="https://cloud.google.com/kubernetes-engine/docs/how-to/configure-backend-service" rel="noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/configure-backend-service</a></p>
