Java High Availability With WildFly on Kubernetes

DZone 's Guide to

Java High Availability With WildFly on Kubernetes

if you need session replication, Wildfly instances need to be clustered. To solve this, you can use the Kubernetes discovery protocol for JGroups: KUBE_PING.

· Java Zone ·
Free Resource

Legacy Java Applications

With the advancement of the dockerization of applications, Kubernetes has become a standard in the market, but we must remember that there are still thousands of legacy applications that depend on certain features provided by the application servers. So, if you need to use session replication, you will surely need Wildfly instances to be clustered. To solve this smoothly, you can use the “Kubernetes discovery protocol for JGroups” aka “KUBE-PING”. KUBE_PING is a discovery protocol for JGroups cluster nodes managed by Kubernetes: jgroups-kubernetes.


I assume you already have a Kubernetes cluster, so let’s just focus on WildFly settings.

The first step is to create a repository that will contain all our files:


Then create a Dockerfile with the necessary steps for image customization:


In the same directory, create the file “config-server.cli”, which will contain the steps to configure kubeping correctly:


Now put the “package of your application” to the directory “application”


The next step is to create all Kubernetes objects so we can do the tests later. I’m using the namespace “labs”:


Now just run the image build and push this to the docker hub or any other “registry”:



[root@workstation ~]# docker build -t mmagnani/wildfly20-kubeping:latest . 
[root@workstation ~]# docker push mmagnani/wildfly20-kubeping

In the context of your Kubernetes cluster, just create those objects:


Check the logs. You should find two members as we only define 2 replicas:

Plain Text

As I am using “Traefik”, my “ingress” is available:

Ingress with Traefik

In the application, it is also possible to add the object to the session:

Adding the object to the session

java, kube_ping, kubernetes, session replication, tutorial, wildfly

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}