Enable sticky session in APISIX with discovery type as kubernetes. #11520
Replies: 1 comment
-
Hey @prashantsinghb, I'm here to help you with any issues you're facing. Let's work together to solve the problem. To enable sticky sessions in APISIX with the discovery type as Kubernetes for your React application using the upstream:
name: "example-upstream"
type: roundrobin
discovery_type: "kubernetes"
service_name: "k8s_ns/k8s_service"
timeout:
connect: 6
send: 6
read: 6
plugin_config:
session_sticky:
cookie_name: "connect.sid"
cookie_path: "/"
cookie_domain: "your-domain.com"
cookie_max_age: 3600
mode: "cookie" In this configuration:
Make sure to replace Additionally, ensure that your Kubernetes discovery configuration is properly set up in APISIX. If running inside a Pod, the minimal configuration would be: discovery:
kubernetes: { } If running outside a Pod, you need to specify the Kubernetes API server details and a valid service account token: discovery:
kubernetes:
service:
schema: https
host: # enter apiserver host value here
port: # enter apiServer port value here
client:
token: # enter serviceaccount token value here This ensures that APISIX can discover the Kubernetes services correctly and apply the sticky session configuration [1][2]. |
Beta Was this translation helpful? Give feedback.
-
Need help in enabling sticky session for an application routed via APISIX.
upstream:
-
id: 1
type: chash
hash_on: cookie
key: connect.sid
discovery_type: kubernetes
service_name: k8s_ns/k8s_service
Have already gone through https://dev.to/apisix/sticky-sessions-with-apache-apisix-3l03, but it is not working for me.
Beta Was this translation helpful? Give feedback.
All reactions