Giter Site home page Giter Site logo

yersan / jboss-on-aro-jakartaee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-javaee/jboss-on-aro-jakartaee

0.0 1.0 0.0 254 KB

A tutorial showing how to run a Jakarta EE App on JBoss EAP and Azure Red Hat OpenShift

License: MIT License

Java 56.05% HTML 43.95%

jboss-on-aro-jakartaee's Introduction

JBoss EAP on Azure Red Hat OpenShift example

This project is a simple todo-list demo application used to walk you through the process of migrating a traditional Jakarta Faces / Jakarta Enterprise Beans / Jakarta Persistence application to a container orchestrator like Red Hat OpenShift running on Azure.

Getting Started

Prerequisites

Azure Red Hat OpenShift requires a minimum of 40 cores to create and run an OpenShift cluster. The default Azure resource quota for a new Azure subscription does not meet this requirement. To request an increase in your resource limit, see Standard quota: Increase limits by VM series. Note that the free trial subscription isn't eligible for a quota increase, upgrade to a Pay-As-You-Go subscription before requesting a quota increase.

  1. Prepare a local machine with a Unix-like operating system that is supported by the various products installed (for example Red Hat Enterprise Linux 8 (latest update) in the case of JBoss EAP).

  2. Install a Java SE implementation (for example, Oracle JDK 11).

  3. Install Maven 3.6.3 or higher.

  4. Install Docker for your OS.

  5. Install Azure CLI 2.29.2 or later.

  6. Clone the code for this demo application (todo-list) to your local system. The demo application is at GitHub.

  7. Follow the instructions in Create an Azure Red Hat OpenShift 4 cluster.

    Though the "Get a Red Hat pull secret" step is labeled as optional, it is required for this article. The pull secret enables your ARO cluster to find the JBoss EAP application images.

    If you plan to run memory-intensive applications on the cluster, specify the proper virtual machine size for the worker nodes using the --worker-vm-size parameter. For more information, see:

  8. Connect to the cluster by following the steps in Connect to an Azure Red Hat OpenShift 4 cluster.

    • Follow the steps in "Install the OpenShift CLI"
    • Connect to an Azure Red Hat OpenShift cluster using the OpenShift CLI with the user kubeadmin
  9. Execute the following command to create the OpenShift project for this demo application:

    $ oc new-project eap-demo
    Now using project "eap-demo" on server "https://api.zhbq0jig.northeurope.aroapp.io:6443".
    
    You can add applications to this project with the 'new-app' command. For example, try:
    
    oc new-app rails-postgresql-example
    
    to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application:
    
    kubectl create deployment hello-node --image=k8s.gcr.io/serve_hostname
  10. Execute the following command to add the view role to the default service account. This role is needed so the application can discover other pods and form a cluster with them:

    $ oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)
    clusterrole.rbac.authorization.k8s.io/view added: "system:serviceaccount:eap-demo:default"

Demo

The demo application is a simple Jakarta EE 8 application that creates, reads, updates, and deletes records on a Microsoft SQL Server. This repository is split up into the following branches:

  • main: Basic Jakarta EE 8 application (Jakarta Faces / Jakarta Enterprise Beans / Jakarta Persistence)
  • bootable-jar: Basic Jakarta EE 8 application converted into a JBoss EAP Bootable JAR and using MicroProfile 4.0 specs.
  • bootable-jar-openshift: Built on top of the bootable-jar branch, this is the application prepared to be deployed on ARO.

In the following steps, we will do a quick deployment of the Microsoft SQL server and application on ARO cluster. We will use the application code from the bootable-jar-openshift branch.

Please, check the full guide that uses this demo at the Java EE, Jakarta EE, and MicroProfile on Azure documentation.

Deploy the database server on ARO

Execute the following steps to deploy the Microsoft SQL Server and create the database used by the application:

  1. Create an OpenShift Secret object that will hold the configuration relative to the database:

     todo-list (bootable-jar-openshift) $ oc create secret generic mssqlserver-secret \
     --from-literal db-password=Passw0rd!
     secret/mssqlserver-secret created
  2. Deploy the database server by executing the following:

    todo-list (bootable-jar-openshift) $ oc apply -f ./deployment/msqlserver/mssqlserver.yaml
    service/mssqlserver created
    deploymentconfig.apps.openshift.io/mssqlserver created
    persistentvolumeclaim/mssqlserver-pvc created
  3. Monitor the status of the pods and wait until the database server is running:

    todo-list (bootable-jar-openshift) $ oc get pods -w
    NAME                   READY   STATUS      RESTARTS   AGE
    mssqlserver-1-deploy   0/1     Completed   0          34s
    mssqlserver-1-gw7qw    1/1     Running     0          31s
  4. Connect to the database pod and create the database todos_db:

    todo-list (bootable-jar-openshift) $ oc rsh mssqlserver-1-gw7qw
    sh-4.4$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Passw0rd!'
    1> CREATE DATABASE todos_db
    2> GO
    1> exit
    sh-4.4$ exit
    exit

Deploy the application on ARO

Execute the following steps to build and deploy this demo application on ARO by using the OpenShift CLI:

  1. Compile the demo application and create the Bootable JAR:

    todo-list (bootable-jar-openshift) $ MSSQLSERVER_DRIVER_VERSION=7.4.1.jre11 \
    mvn clean package -Pbootable-jar-openshift
  2. Execute the following commands to create an application image:

    todo-list (bootable-jar-openshift) $ mkdir target/openshift && cp target/todo-list-bootable.jar target/openshift
    todo-list (bootable-jar-openshift) $ oc import-image ubi8/openjdk-11 --from=registry.redhat.io/ubi8/openjdk-11 --confirm
    todo-list (bootable-jar-openshift) $ oc new-build --strategy source --binary --image-stream openjdk-11 --name todo-list-app
    todo-list (bootable-jar-openshift) $ oc start-build todo-list-app --from-dir target/openshift 
  3. Deploy the application and expose it:

    todo-list (bootable-jar-openshift) $ oc new-app todo-list-app \
    --env KUBERNETES_NAMESPACE=$(oc project -q) \
    --env MSSQLSERVER_PASSWORD=Passw0rd! \
    --env MSSQLSERVER_USER=sa \
    --env MSSQLSERVER_DATABASE=todos_db \
    --env MSSQLSERVER_JNDI=java:/comp/env/jdbc/mssqlds \
    --env MSSQLSERVER_HOST="\$(MSSQLSERVER_SERVICE_HOST)" \
    --env MSSQLSERVER_PORT="\$(MSSQLSERVER_SERVICE_PORT)" \
    --env JGROUPS_CLUSTER_PASSWORD=mut2UTG6gDwNDcVW
  4. Expose the application through an OpenShift service:

    todo-list (bootable-jar-openshift) $ oc expose svc/todo-list-app
  5. Get the public URL of the application:

    todo-list (bootable-jar-openshift) $ echo "http://"$(oc get route todo-list-app --template='{{ .spec.host }}')
    http://todo-list-app-eap-demo.apps.bry1besb.northeurope.aroapp.io
  6. Open the URL with your favourite web browser. The application will look similar to the following image:

    Application home on ARO

Resources

You can learn more from references used in this guide:

jboss-on-aro-jakartaee's People

Contributors

microsoftopensource avatar yersan avatar microsoft-github-operations[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.