<p>I have keycloak installed on kubernetes by oficial helm chart. I have 2 replicas on a statefulset. I have created a realm and configure the admin-cli client to go by confidential. When I ask for a token by this client (with the correct client secret), I get the token, and when I try to create a user, sometimes the curl works, and sometimes I get an unauthorized error. I tried to set only 1 replica and always works fine, but with more than 1 replica, curl sometimes works, sometimes doesn't. I think the problem is between the pods, the sync between pods or something like this. Can anyone helps me?</p>
<p>Thanks</p>

EMG
<p>Just setting 2 replicas doesn't mean that Keycloak runs in a cluster, it's just a K8s cluster, but not a Keycloak cluster. How should Keycloak know, if you don't tell it?</p>
<p>You'll have to configure Infinispan and JGroups properly, using some <code>*_PING</code> method for node discovery. Try using <code>JDBC_PING</code>, <code>DNS_PING</code> or <code>KUBE_PING</code>. See <a href="http://www.jgroups.org/manual4/index.html#protlist" rel="nofollow noreferrer">JGroups docs</a> for more details.</p>
<p>See also for example my YouTube video on Keycloak clustering: <a href="https://youtu.be/P96VQkBBNxU" rel="nofollow noreferrer">https://youtu.be/P96VQkBBNxU</a></p>
