@pierreozoux @dasniko Finally, I found the solution.
I have to insert the following script to the Keycloak Image: (keycloak.cli)
embed-server --server-config=standalone-ha.xml --std-out=echo
batch
/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions:write-attribute(name=owners, value=${env.CACHE_OWNERS_COUNT:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS_COUNT:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions:write-attribute(name=owners, value=${env.CACHE_OWNERS_COUNT:1})
/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures:write-attribute(name=owners, value=${env.CACHE_OWNERS_COUNT:1})
echo Configuring node identifier
/subsystem=transactions:write-attribute(name=node-identifier, value=${jboss.node.name})
run-batch
stop-embedded-server
The Dockerfile:
FROM quay.io/keycloak/keycloak:12.0.4
RUN mkdir /opt/jboss/startup-scripts/
COPY keycloak.cli /opt/jboss/startup-scripts/
The environment for Keycloak container:
If you deploy Keycloak with Replicas = 5
name: CACHE_OWNERS_AUTH_SESSIONS
value: "5"
name: JGROUPS_DISCOVERY_PROTOCOL
value: dns.DNS_PING
name: JGROUPS_DISCOVERY_PROPERTIES
value: 'dns_query=${keycloak-svc}.${namespace}.svc.cluster.local'
name: CACHE_OWNERS_COUNT
value: "5"
name: CACHE_OWNERS_AUTH_SESSIONS_COUNT
value: "5"
For more detail: