<p>I have a keycloak and client application on one Kubernetes node. I have 3 pods for keycloak and client Can I manage traffic in kubernetes so that the query from the client replica to the keycloak always returns to the same replica from which it comes? For now, traffic is being redirected </p>

<pre><code>client replica -&gt; keyclok -&gt; random client replica.
</code></pre>

<p>I want to get effect:</p>

<pre><code>client replica x -&gt; keycloak -&gt; client replica x.
</code></pre>

<p>Thank you in advance for all the answers</p>

ph_anvin
<p>This feature is called sticky sessions, can be configured in Nginx ingress controller following these annotations:</p>

<p><a href="https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/</a></p>

<p>If you have everything deployed in AWS and you are using an ALB ingress controller, you can achieve this with stickiness annotation.</p>

<p>My working in production example:</p>

<pre><code>alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=6000
</code></pre>
