Running Scala microservices on Open Liberty and Kubernetes
This blog post shows how Open Liberty microservices can be implemented using the Scala language and deployed on to a Kubernetes cluster. The main focus of the project was to explore the technical feasibility of integration between Open Liberty and Scala.
Docker image creation
The base Docker image for Open Liberty is already available on Docker Hub. Available documentation on openliberty.io provides information how to use this Docker image when using a Java and Maven toolset to create an application image, and the challenge was to analyze and replicate the same behaviour of creating an image but using a Scala and sbt toolset, with some additional sbt plugins as required. An existing example application created by Maven was analyzed to investigate an internal structure of an application WAR file, which was then used to correctly parametrize the sbt-docker plugin. Details on creating and testing Docker images can be found at README: Docker.
Running on Kubernetes
The application Docker image was deployed on a Kubernetes cluster and all required deployments and services were created. The services worked correctly, which showed no interoperability issues between Open Liberty and classes as compiled by Scala. All annotations defined on classes and methods were correctly retained in runtime and then correctly picked up and used by Open Liberty. Details can be found at README: Kubernetes.
Notes on performance
It may be worth mentioning that the application is ready to serve requests in about 60s mark (as measured on the hosts used - AWS t2.nano), so this factor may need to be taken into account in use cases in which it is important.
Conclusion
This example project showed that it is practically possible to use Open Liberty-based microservices from a Scala application, and the ease-of-use and implementation is the same as with Java-based applications. The project can be found at GitHub: scala-openliberty-mandelbrot