Keycloak cluster using docker swarm3 min read
Hi All, this document deals with how to set up a keycloak cluster using a docker swarm.
Keycloak is an open-source software product to allow single sign-on with Identity Management and Access Management aimed at modern applications and services. As of March 2018, this JBoss community project is under the stewardship of Red Hat who uses it as the upstream project for their RH-SSO product.
- Docker swarm
- Mysql/MariaDB database setup for keycloak applications.
- docker compose
You can build your keycloak application from the below Dockerfile.
Before building a docker image. download the following files.
Create the docker file.
Build the docker image
Now you can see the docker image got created.
Let’s configure the keycloak cluster.
Create a docker-compose file with the following configuration.
DB_PASSWORD keycloak database user password
KEYCLOAK_PASSWORD: keycloak console password
DB_DATABASE: keycloak database name
KEYCLOAK_USER: keycloak console admin user
Here we are running 3 docker containers in a cluster, maintaining a minimum of 3 containers will avoid split-brain while cluster resyncing.
Now let’s deploy the stack.
Now you can see containers are starting up. You can see the dockers of the entire stack using below command
You can check the status of the container using the below command and wait for the containers to be healthy.
Or else you can check individual container logs using below command,
Once containers are healthy, browse http://IP:8080 for Keycloak application console login.