When a user initially accesses a service behind the Application Gateway, the gateway assigns a unique identifier (a cookie) to that user’s session. For subsequent requests from the same user, the gateway uses this cookie to ensure that the requests are routed to the same backend server that handled the initial request. This helps maintain session state and can be useful for scenarios where stateful operations need to be performed across multiple requests from the same user.
If you want to enable cookie based affinity with application gateway using application gateway ingress controller you can use following annotation :
appgw.ingress.kubernetes.io/cookie-based-affinity: “true”
An example configuration to show how to use it in ingress file :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: guestbook
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/cookie-based-affinity: “true”
spec:
rules:
– http:
paths:
– backend:
serviceName: frontend
servicePort: 80
I hope this will help you . For more such blogs keep exploring nashtech blogs .
