If you have just one pod, all the traffic is forwarded to one single container, but if you have multiple pods, the K8S service load balances the traffic.
When you create a user session in one container, there’s no replication mechanism to propagate this session in the other running containers, so you have to authenticate again and again.
To solve the issue, you can try configuring session affinity in the K8S service, following this example:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 5555
targetPort: 5555
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800 # Or any other suitable duration
But you need to be very cautious when doing it, because you change the load balancing algorithm.
Here’s what I advise you to do:
- create one or several custom port to deal with your integrations (serve API calls, for instance), with K8S services that have no session affinity at all
- restrict port 5555 to the admin console, and here you can configure session affinity if you want
- restrict usage of the admin console in production to monitoring use cases. Everything that is related to deployment and configuration should be fully automated, you should never use the console to deploy a package, configure a resource or change a server setting
#webMethods#Integration-Server-and-ESB