i'm running a flask-socketio behind an ingress. here's the config:
socketio = SocketIO(app, message_queue='redis://redis-server.domain:6379')
in the dockerfile, it runs like so:
CMD ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "4", "--bind", "0.0.0.0:2731", "app:app"]
and the ingress is configured like this:
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/enable-ssl-passthrough: "true"
nginx.ingress.kubernetes.io/session-cookie-name: "route"
i also tried replacing "cookie" with "ip_hash"
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.
any ideas?
Ideally, it should have worked but try this .spec.sessionAffinity
Set it to service
.spec.sessionAffinity
value will be ClientIP
Service to POD sticky session
kind: Service
apiVersion: v1
metadata:
name: test-service
spec:
selector:
app: test-app
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
sessionAffinity: ClientIP