Skip to content

redhat-developer-demos/monolith-to-containerized

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenShift Monolithic to Containerized


Purpose

The purpose of this is to demonstrate the introduction of an OpenShift containerized implementation into an existing legacy infrastructure. We will illustrate how to continue running your current legacy applications as they are while adding on to them and migrating portions over to a new containerized OpenShift environment.

In order to achieve this, we will first install Wildfly/JBoss and deploy a simple web application packaged as a war. This application has an HTML/JavaScript front end calling restful Java WebServices to display various 'hello world' messages.

Legacy Application

Once the legacy application is up and running, we will introduce new services implemented as Java services and Bonjour services. These new services are taken from the OpenShift MSA Demo https://github.com/redhat-helloworld-msa and will be deployed in an OpenShift. Once deployed, these services will be integrated in to the front end of the existing legacy application as shown below.

Hybrid Application

Now that we have the two technologies up and running side by side, we can start to migrate existing legacy portions of the application over to OpenShift. In this case, we can continue to run the old legacy services in parallel until all consumers have migrated over to the new OpenShift service and then decommission it.

Hybrid Application

Prerequisites

Download the Demo

Clone the github repository

$ git clone https://github.com/redhat-developer-demos/monolith-to-containerized.git

Configure Demo

To install both the legacy and OpenShift portions of the demo, some information is required. First edit the hosts files and set the IP addresses for the hosts to install the two applications.

$ vi <demoROOT>/monolith-to-containerized/ansible/hosts

[legacy-servers]
192.168.223.43

[ocp-servers]

192.168.223.43

Now modify the following to match your environment

$ vi <demoROOT>/monolith-to-containerized/ansible/group_vars/user-vars.yaml

# A temporary directory for any required temporary downloads # Must be a directory with read/write permissions
tmp_dir: /tmp

# The location of the cloned github repository # Must be a directory with read/write permissions
plusone_home: /home/user/development/monolith-to-containerized

# The location to install wildfly # Must be a directory with read/write permissions
wildfly_home: /opt/testwildfly

# Automatically install the legacy application
install_legacy_application: true

# The location to install the OpenShift Client tools (oc) # Must be a directory with read/write permission
oc_install: /opt/testopenshift

# Automatically install the MSA services
install_msa_application: true

Option 1 - From Binaries

To make it easier and remove dependencies on build tools, all source has been compiled/packaged and has been downloaded when cloning the github repository above.

Step 1 - Run Ansible to Install the Monolithic Application

In order to make the install quick and easy, the following Ansible Playbook can be executed to get the monolithic application up and running.

The Playbook will perform the following

  1. Check if Wildfly exists at the location given above, if so, step 2 is skipped.
  2. Download and install Wildfly (http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip)
  3. Deploy the precompiled war file downloaded as part of the git clone above (/monolith-to-containerized/monolithic/bin/openshift-next-monolithic.war)
	$ cd <demoROOT>/monolith-to-containerized/ansible
	$ ansible-playbook -i hosts legacy.yml

Once the script has completed the Legacy Application will be accessible via http://monolithic-host:8080/openshift-next-monolithic

Also, you may access the Wildfly admin console via http://legacy-host:9990 and follow the instructions there to add users to enable the console.

Step 2 - Run Ansible to Install OpenShift Services

In this demo, we will be using oc cluster up https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md#overview.

Please read https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md#linux and ensure all steps prior to the oc cluster up command have been performed

The Playbook will perform the following tasks

  1. Check if the oc exists in the previously configured location, if so, step to is skipped
  2. Download and install the oc command
  3. Download and start the OpenShift docker image
  4. Deploy 3 pre-built MSA services from /monolith-to-containerized/msa/* using the Dockerfiles and binaries contained within
  5. Expose the services so they are accessible
	$ cd <demoROOT>/monolith-to-containerized/ansible
	$ ansible-playbook -i hosts openshift.yml

While the script is running, the OpenShift console will be accessible once the oc cluster up command has completed. It can be accessed at http://< ocp-server>:8443/console with user: developer and password: developer. As the ansible script progresses, a helloworld-msa project will appear.

Option 2 - From Source

###Additional Prerequisites In addition to the main prerequisites above, the following are required to compile and deploy the source in the following sections.

  • Maven
    • version >= 3.3
  • NPM
    • version >= 2.15

Step 1 - Build and Deploy Monolithic Application

With Wildfly or JBoss running, execute the following

$ cd <demoROOT>/monolith-to-containerized/monolithic
$ mvn clean install wildfly:deploy

Step 2 - Download the Source for the MSA services

oc login <ocp-server>:8443 -u developer -p developer

Build and Deploy Hola Service

$ cd <MSAWorkingDirectory>
$ git clone https://github.com/redhat-helloworld-msa/hola
$ cd hola/
$ oc new-build --binary --name=hola -l app=hola
$ mvn package; oc start-build hola --from-dir=. --follow
$ oc new-app hola -l app=hola,hystrix.enabled=true
$ oc expose service hola

Build and Deploy Ola

$ cd <MSAWorkingDirectory>
$ git clone https://github.com/redhat-helloworld-msa/ola
$ cd ola/
$ oc new-build --binary --name=ola -l app=ola
$ mvn package; oc start-build ola --from-dir=. --follow
$ oc new-app ola -l app=ola,hystrix.enabled=true
$ oc expose service ola

Build and Deploy Bonjour

$ cd <MSAWorkingDirectory>
$ git clone https://github.com/redhat-helloworld-msa/bonjour
$ cd bonjour/
$ oc new-build --binary --name=bonjour -l app=bonjour
$ npm install; oc start-build bonjour --from-dir=. --follow
$ oc new-app bonjour -l app=bonjour
$ oc expose service bonjour

Running through the Demo

http://localhost:8080/plusone-legacy-application/services.json

$ vi <wildfly_home>/wildfly-10.0.0.Final/welcome-content/services.json

{ "hello-service": { "url": "http://192.168.223.43:8080/openshift-next-monolithic/rest/hello" }, "hola-service": { "url": "http://192.168.223.43:8080/openshift-next-monolithic/rest/hola", "url-move": "http://hola-helloworld-msa.192.168.223.43.xip.io/api/hola", "url-legacy": "http://192.168.223.43:8080/openshift-next-monolithic/rest/hola" }, "bonjour-service": { "url": "http://bonjour-helloworld-msa.192.168.223.43.xip.io/api/bonjour" }, "ola-service": { "url": "http://ola-helloworld-msa.192.168.223.43.xip.io/api/ola" } }

Monolithic Application

http://monolithic-host:8080/openshift-next-monolithic/monolithic.html

Hybrid Application

http://monolithic-host:8080/openshift-next-monolithic/hybrid.html

Migrating Application

http://monolithic-host:8080/openshift-next-monolithic/migrate.html

Troubleshooting

Notes

$ kill -9 `fuser -f nohup.out`
$ docker stop origin `docker ps -q`

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published