I'm running a wordpress / woocommerce site on GCE Kubernetes and having trouble scaling because of session persistence.
The LoadBalancer (GCE Ingress) sends all traffic to a reverse proxy that then sends the traffic to different services I have set up, one of which is wordpress.
If I use SessionAffinity: ClientIP
on the WordPress service all of the traffic goes to one pod and the others are ignored. This seems to because the service is seeing the LoadBalancer's ip address rather than the Client's. This is in spite of externalTrafficPolicy: Local
set on both nginx reverse proxy and the wordpress NodePort services.
I've also tried using the wordpress service as the default backend and I managed to get traffic to go to all pods but lost session affinity.
The Ingress also performs TLS termination, which I've seen can effect ClientIP visibility, but I think that issue is resolved by the external traffic policy.
We are also using Cloudflare, I'm wondering if that could have an effect. But we are using the ngx_http_realip_module to try to get the correct Client IP address.
I had a similar issue in one of the PHP services deployed in my cluster. Sessions are evil :) but sometimes you do need to use them. You can cluster your session data in PHP in couple ways, so that you do not need to use sticky sessions on loadbalancer(s).
You can find simple mamcache example here. If you'd need a clustered storage, you could look into Redis clustering, or, as I would, into Couchbase