Java High Availability With WildFly on Kubernetes
Join the DZone community and get the full member experience.
Join For Freelegacy 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:
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”:
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:
as i am using “traefik”, my “ingress” is available:
in the application, it is also possible to add the object to the session:
Opinions expressed by DZone contributors are their own.
Comments