<p>i'm running a flask-socketio behind an ingress.
here's the config:</p>
<pre><code>socketio = SocketIO(app, message_queue='redis://redis-server.domain:6379')
</code></pre>
<p>in the dockerfile, it runs like so:</p>
<pre><code>CMD [&quot;gunicorn&quot;, &quot;-k&quot;, &quot;geventwebsocket.gunicorn.workers.GeventWebSocketWorker&quot;, &quot;-w&quot;, &quot;4&quot;, &quot;--bind&quot;, &quot;0.0.0.0:2731&quot;, &quot;app:app&quot;]
</code></pre>
<p>and the ingress is configured like this:</p>
<pre><code>nginx.ingress.kubernetes.io/affinity: &quot;cookie&quot;
nginx.ingress.kubernetes.io/enable-ssl-passthrough: &quot;true&quot;
nginx.ingress.kubernetes.io/session-cookie-name: &quot;route&quot;
</code></pre>
<p>i also tried replacing &quot;cookie&quot; with &quot;ip_hash&quot;</p>
<p>whenever i add a second replica pod, it starts returning error 400, as if it contacts the pods interchangeably, and not sticking to the same server, thus breaking the socket.</p>
<p>any ideas?</p>

Benny
<p>Ideally, it should have worked but try this <strong>.spec.sessionAffinity</strong></p>
<p>Set it to <strong>service</strong></p>
<p><code>.spec.sessionAffinity</code> value will be <strong>ClientIP</strong></p>
<p><strong>Service</strong> to <strong>POD</strong> sticky session</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: test-service
spec:
  selector:
    app: test-app
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
  sessionAffinity: ClientIP
</code></pre>
