Deploying a Jakarta EE Application to a Kubernetes Cluster in Jelastic PaaS
Recently, Jelastic was asked to sponsor cloud hosting of a Jakarta EE blueprint application called Cargo Tracker. As a member of the Jakarta EE Working Group, we wanted to support the community, so we’re now running the application at Scaleforce, one of our platform as a service (PaaS) providers. To help other developers learn how to deploy Jakarta EE applications to a Kubernetes cluster in Jelastic PaaS, we’re using this article to share the steps we followed.
First, a bit of background.
Cargo Tracker Uses Domain-Driven Design to Power Jakarta EE
Cargo Tracker is a public tracking interface that allows you to track the status and handling history of cargo for which you have a registered tracking ID. The application was developed to demonstrate how developers can use well-established architectural patterns and blueprints to develop real-world applications with Jakarta EE.
Cargo Tracker is created using Domain-Driven Design (DDD), an approach that focuses on the study of a subject area — a domain — and its business processes. Standard programming pays more attention to technologies and infrastructure, and while these aspects are important, they are secondary to business itself. The DDD approach helps developers speak the language of business, the so-called Ubiquitous Language.
The Jelastic team deployed the Cargo Tracker application to the Kubernetes environment using GitHub Actions workflows. The deployment and all data are automatically refreshed nightly. The application is running on a PostgreSQL database in the cloud, and the GitHub Container Registry is used to publish Docker images.
Using Cargo Tracker as an example, here are the steps required to deploy a Jakarta EE application to a Kubernetes cluster in Jelastic PaaS.
The first step is to create a Kubernetes cluster from the Jelastic marketplace. This is a fully automated process, so just follow our tutorial.
The topology of a simple development cluster can look like the example below.
Deploy the Jakarta EE Application
1. Get three config files from the repository:
- The postgres-secret.yaml file provides a database username and password encoded with Base64. This project uses the value “postgres” for both.
- The postgres.yaml file creates a PostgreSQL database.
- The cargo-tracker.yaml file deploys a highly available topology of the Jakarta EE application which consists of two replicas.
2. Use a configuration file manager to create these files on the Control plane node (formerly known as the Master) of the Kubernetes cluster.
Use these files to create the six required Kubernetes resources:
- postgres deployment
- postgres service
- cargo-tracker deployment
- cargo-tracker service
- cargo-tracker ingress
3. Use WebSSH to log in to the Control plane node and apply the files.
But first, check whether the ROOT context path “/” is already used by an ingress resource by typing:
$ kubectl get ing
In the example below, the helloworld application’s ingress is using the “/” context path.
To delete the existing ingress resource shown in the example and release the path for your application, type:
$ kubectl delete ing helloworld
4. Apply the configuration files by typing:
$ kubectl apply -f postgres-secret.yaml
$ kubectl apply -f postgres.yaml
$ kubectl apply -f cargo-tracker.yaml
Test the Jakarta EE Application
Wait for a minute, then check whether the resources have been created and are running by typing:
$ kubectl get secrets
$ kubectl get deploy
2. Click Open in Browser to see the application and verify it works.
3. To confirm the system works, enter the demo tracking ID ABC123 in Cargo Tracker.
Get More Information
Here are a few ways to get more information related to this tutorial:
· Learn more about the Jakarta EE Cargo Tracker demonstration application.
· Review the source code for the Cargo Tracker application.
· Learn more about Jakarta EE and get involved in the community.
About the Author
Tetiana Fydorenchyk is VP of marketing at Jelastic.
More from this Edition
Jan tells us why being a committer is such a great opportunity, and why he would tell developers who are considering getting more involved in Eclipse Foundation projects to “just do it.”
Ivar Grimstad reviews some of the key strategic and technical advantages that make Jakarta EE the ideal choice for organizations developing cloud native enterprise Java applications.