Embracing the Cloud A Java Developer’s Guide to Jakarta EE on The Cloud - A Real-World Example
BuhakeSindi
40 views
45 slides
Jun 14, 2024
Slide 1 of 45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
About This Presentation
This talk will focus either on AWS or Azure (depending on the platform of choice).
This talk provides a comprehensive walkthrough of how to package and deploy Jakarta EE applications to be cloud-ready for deployment.
The session begins with an overview of Jakarta EE and the cloud platform, highlig...
This talk will focus either on AWS or Azure (depending on the platform of choice).
This talk provides a comprehensive walkthrough of how to package and deploy Jakarta EE applications to be cloud-ready for deployment.
The session begins with an overview of Jakarta EE and the cloud platform, highlighting their unique features and advantages. This sets the stage for understanding the synergy between these two powerful platforms.
The core of the session is a detailed, step-by-step tutorial on packaging a Jakarta EE application for the cloud. This covers creating a WAR file, configuring the application for the cloud, and testing the application locally before deployment, then deploying the packaged application to the cloud. This involves creating the cloud App Service, configuring deployment settings, and uploading the WAR file.
Once the application is live, the session explores how to monitor its performance using the cloud’s built-in monitoring tools. Attendees will learn how to interpret these metrics to ensure their application is running optimally.
By attending this session, Java developers will gain a solid understanding of how to leverage the cloud for their Jakarta EE applications. They will leave equipped with practical knowledge and skills to embrace the cloud confidently.
Size: 1.36 MB
Language: en
Added: Jun 14, 2024
Slides: 45 pages
Slide Content
Embracing
the Cloud
A Java Developer’s Guide to Jakarta
EE on The Cloud -A Real-World
Example.
●Senior Full Stack Enterprise Java
Developer, Engineer and
Consultant, Sindi Technologies
(Pty) Ltd
○18+ years of Java development
experience.
●Jakarta EE Ambassador
●Tech speaker / Blogger
●Devoxx4Kids South Africa (Non-
Profit Organisation) founder and
event organiser
About Me
Where to find me?
https://linktr.ee/theEliteGentleman [email protected]
@EliteGentleman
www.sindi.co.za
www.devoxx4kids.org.za
https://jakartaee-ambassadors.io/
To my
parents…
What (is it) exactly do I do for a living?
●Business brings problems that they want solution to make it go
away.
●I scope their problem into a solution.
●-> -> ->
(code) (build) (deploy) (ship)
●Programming language: Java (as in )
●Preferred framework to build business applications using Java:
Jakarta EE (previously known as Java EE). EE -> Enterprise Edition.
I foresee every step of the business lifecycle of the project, from
inception to release.
A glorified work life
Your JakartaEE
application
Configuration settings and
infrastructures
01
●A Health provider medical claim system.
●Written fully in Java
○Mavenised
○JDK 17+
○Jakarta EE 10 (Faces 4, CDI, JPA with JNDI DataSource, Jakarta SOAP
WS –JAX-WS, Jakarta REST –JAX-RS, JavaMail)
○Certificates (HTTP security), static IP addresses for HTTP transport
communication
●Database
○PostgreSQL 16.2 or higher
●Application server
○Any Jakarta EE 10 certified product –OpenLiberty24.0.0.1 or higher
Introducing Kuanza
Getting started
●https://start.jakarta.ee
●For starting your Jakarta EE
journey from scratch.
●Generate MavenizedJakarta
EE projects
●Supported via popular IDEs
oIntelliJ, NetBeans, Eclipse, Visual
Studio Code.
Prepping for
cloud-readiness
02
●Containerization
○Only your application code is bundled, as well as all necessary files,
libraries and Operating System libraries and dependencies required to
run the code are packaged into a single executable (container) that
runs on any infrastructure.
●Benefits
○Portability: A container can run on multiple infrastructure and
environments without changing code.
■Prevent “But it does work on my machine” problem.
○Scalable: Containers are lightweight. Bootup is faster (no OS bootup
needed). Multiple containers can run on a single machine.
○Isolation: Containers doesn’t require knowledge of hardware and OS.
Prepping for cloud-readiness
●Containerized
○Simplified to run on any platform.
■Prevent “But it does work on my machine” problem.
○Containerized PostgreSQL database.
○Containerized OpenLibertyApplication Server.
●Cloud Provider of choice: Azure
○Quick response time to enterprise customer problem.
○Business chose this.
○Not sponsored talk by Microsoft! (No joke!)
For Kuanza
https://www.slideshare.net/BuhakeSindi/dockerizing-
your-java-development-environment
Let’s hack with
Azure
Get your DevOps hat ready!
03
●Azure subscription.
○Get an Azure account, get a subscription ID.
○Get an Azure region location for your region group.
●Install Azure CLI
●Basic knowledge of Linux
○Commands such as: chown, wget, curl, cat, etc.
○Windows: Use WSL (Windows Subsystem for Linux), notGit Bash
●Basic knowledge of Docker scripting (Dockerfileand/or Docker
compose)
Requirements
●Azure Resource Group (cluster everything in 1 resource group)
●Azure for PostreSQLSingle Server *
○* Soon to be replaced with Azure PostgreSQL Flexible Server
(single server will be decommissioned in 2025 by Microsoft)
●Azure Container Registry (Private Docker Registry)
●Azure Container Instance (containerapp)
●Azure Kubernetes Service (AKS) –should you need advanced
metrics that Kubernetes provides.
○Not used for this presentation.
Azure services
●https://portal.azure.com/
○View the progress of your services that you create.
○Useful for monitoring of your services to make decisions such as scaling.
Azure Portal
●Login to your Azure cloud using Azure CLI
○Grab the subscription ID once you’ve successfully logged in.
○Command: azlogin
1. Login to Azure
●Command: azaccount set
2. Set subscription, if necessary
●Command: azaccount list-locations -o table
3. Select a region
●A resource group contains all your services (resources) which you
create.
○Useful for managing all your resources as a group.
●Command: azgroup create
4. Create a Resource Group
●Azure for PostgreSQL Database is a relational database service based on
open-source Postgres database engine. It is fully managed database-as-a-
service offering which is available with 2 different offerings: Single Server and
Flexible Server.
○For this presentation, we’ve used Single Server offering.
○Documentation:
■Flexible Server: https://learn.microsoft.com/en-us/azure/postgresql/
■Single Server: https://learn.microsoft.com/en-us/azure/postgresql/single-
server/concepts-servers
●Command: azpostresserver create
5a. Install PostgreSQL on Azure
5. Install PostgreSQL on Azure
5. Install PostgreSQL on Azure
●Once your server has been created, the fully qualified domain name of your
PostgreSQL server should be in the format:
[AZURE_POSTGRES_SERVER_NAME].postgres.database.azure.com
●This can be retrieved from the JSON response value of
fullyQualifiedDomainName
●Command: azpostgresserver show
5b. Verifying PostgreSQL on Azure
5b. Verifying PostgreSQL on Azure
●Azure PostgreSQL server is secured by default. It doesn’t accept
incoming connection.
○1. Get IP address from your IP address. For WSL users, use cat
/etc/resolve.confto get IP address.
6. Setup Azure Firewall Rule for PostgreSQL Server
●From Azure Portal (under Connection security in my database)
6. Setup Azure Firewall Rule for PostgreSQL Server
●The PostgreSQL server that you created earlier is empty. We need
to create a new database.
●Command: azpostgresdbcreate
Create PostgreSQL Database
●Login to your empty database (with admin credentials) and run the following
script.
Create non-admin (superuser) user and grant
●The default Azure JDBC URL for the PostgreSQL Server is of the format:
jdbc:postgresql://{AZURE_POSTGRES_SERVER_NAME}.postgres.database.azure.com:5432
/{AZURE_POSTGRES_SERVER_DATABASE_NAME}?user={DATABASE_USER}@{AZURE_PO
STGRES_SERVER_NAME}?&password={DATABASE_PASSWORD}&sslmode=require
●On OpenLiberty(inside your server.xml):
<properties.postgresqlURL="jdbc:postgresql://kuanza-
db.postgres.database.azure.com:5432/kuanza_db?user=kuanza_root@kuanz
a-
db&password={PASSWORD}& amp;sslmode=require&stringtype=u
nspecified" />
JDBC URL
●Azure Container Registry is a managed, private Docker Registry
service to store and manage your Docker container images (based
on Open-source Docker Registry 2.0)
●There are 4 SKU available when creating your ACR: Basic, Classic,
Premium, Standard.
●Our Jakarta EE Application Docker image will be stored here.
●Command: azacrcreate
7a. Setup Azure Container Private Registry
●Login to ACR to get the ACR server name
○ACR server name is of format [ACR_NAME].azurecr.io
●Command: azacrlogin
●Command: azacrshow
7a. Login to Azure Container Private Registry
●Build your Jakarta EE project into a WAR file
○Command: mvnclean package
●Build the Docker Image and push it to the Azure Container
Registry.
8. Build and push the image to Azure Container
Registry
●Azure Container Instances allows you to run a container in Azure
without having to manage any VMs and/or adopt any higher -level
services.
●We are now ready to deploy our Jakarta EE application to Azure
Container Instances. When deploying to ACI, you need to specify a
custom DNS name.
9. Deploy the application to Azure Container Instances
●We will need the password for Azure Container Registry
●Command: azacrcredential show
9. Deploy the application to Azure Container Instances
●Create the container with the password provided previously
●Command: azcontainer create
9. Deploy the application to Azure Container Instances
●Result is default JSON format
9. Deploy the application to Azure Container Instances
●http(s)://[DNS_NAME_LABEL].[AZURE_LOCATION].azurecontainer.i
o[:PORT]/
●For Kuanza:
https://kuanza.southafricanorth.azurecontainer.io:9443/
Result
Further
improvement…
04
●Automated Deployment
○CI/CD build tools (Jenkins, BitBucket)
●Monitoring of resources
○For up/down scaling of resources as needed, over time.
●Automation of Cloud Infrastructure
○Terraform
●Applying custom domain to resources.