Java High Availability With WildFly on Kubernetes

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 .

walkthrough

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:

shell


then create a dockerfile with the necessary steps for image customization:

dockerfile


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

shell


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

shell


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

dockerfile


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

shell




xxxxxxxxxx
1


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



in the context of your kubernetes cluster, just create those objects:

shell


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

 

 

 

 

Top