Table of Contents

AKS: Cookie based session affinity Configuration

We are facing an issue with session affinity when we increase the Replicas in the cluster; the problem is when we log in to the website, there is authentication. We are getting authentication many times at the time of login.  

Here I explained why we are getting this issue and how we resolved this.  

When using a single pod in the cluster, we don’t get any authentication error because when the user hits the website load-balancer, the traffic goes to that single replica. It will redirect to the authentication request, and it will succeed if the traffic hits a single pod.  

In our case, when we increased the replica count, the application was not stable and asked for authentication multiple times and failed because the LB traffic was unable to select the right pod. 

Session affinity uses cookies to track session information and potentially maintain login credentials. With session affinity, the application server that handles the first client request generates session information and places it in a Set-Cookie header in the response.  

For this issue, we used to need some corrections in Ingress rules, so we added cookies-based-affinity is true in application gateway Ingress rules, and we can use Sticky sessions or session affinity also. We can give a time limit also for the session. 

For this solution, we solved this issue, and traffic goes to both pods, and the session is saved.

Read this E-Book to get a pulse on Elasticsearch monitoring.

Are you monitoring your Elasticsearch environment to detect problems like unreliable nodes and out-of-memory errors? Know which metrics to monitor & where to start.

Cloud Engineer

Gabriel Chutuape

A technology enthusiast passionate about automation, Gabriel Chutuape is a Cloud Engineer at ISmile Technologies. He’s part of the ISmile Technologies Cloud enablement team that help customers to design/solution/project engineering, integrating and implementing infrastructure technologies & services.

CLOUD Engineer

Gopi Krishna

I’m working as Cloud DevOps Engineer. Expertise in technologies of Kubernetes, cloud services and cloud-native services, and DevOps technologies in various clouds.

Liked what you read !

Please leave a Feedback

Leave a Reply

Your email address will not be published. Required fields are marked *

Join the sustainability movement

Is your carbon footprint leaving a heavy mark? Learn how to lighten it! ➡️

Register Now

Calculate Your DataOps ROI with Ease!

Simplify your decision-making process with the DataOps ROI Calculator, optimize your data management and analytics capabilities.

Calculator ROI Now!

Related articles you may would like to read

The Transformative Power of Artificial Intelligence in Healthcare
How To Setup An AI Center of Excellence (COE) With Use Cases And Process 

Know the specific resource requirement for completing a specific project with us.


Keep yourself updated with the latest updates about Cloud technology, our latest offerings, security trends and much more.


Gain insights into latest aspects of cloud productivity, security, advanced technologies and more via our Virtual events.

ISmile Technologies delivers business-specific Cloud Solutions and Managed IT Services across all major platforms maximizing your competitive advantage at an unparalleled value.

Request a Consultation