Skip to content

web-servers/tomcat-in-the-cloud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tomcat Clustering in OpenShift

Tomcat-in-the-cloud is the current name of the project that seeks to port Tomcat clustering into cloud services such as Kubernetes and OpenShift.

Try it out with Minishift

Requirements

Setting up the environment

Minishift is a light-weight OpenShift platform that is easy to install and quickly up and running. This platform is perfect for testing out new features like Tomcat-in-the-Cloud. To download and install Minishift, refer to the official documentation.

Once Minishift is installed, proceed with the following instructions :

  1. Start Minishift
$ minishift start
  1. Set up the docker environment
$ eval $(minishift docker-env)
  1. Login with a user/password of your choice. We'll use admin/password
$ oc login -u admin -p password
  1. Create a new project. Again, we will call it tomcat-in-the-cloud but feel free to use the one you'd like
$ oc new-project tomcat-in-the-cloud
  1. Using Docker, log into the running Openshift docker registry
$ docker login -u $(oc whoami) -p $(oc whoami -t) $(minishift openshift registry)
  1. If not already done, clone the repository and change directory to get to its root
$ git clone https://github.com/web-servers/tomcat-in-the-cloud.git
$ cd tomcat-in-the-cloud
  1. Build the docker image providing the war file of the application you would like to deploy (relative path). You also have to specify the registry_id which is the name of your Openshift project
$ docker build --build-arg war=[war_file] --build-arg registry_id=$(oc project -q) . -t $(minishift openshift registry)/$(oc project -q)/image

The name of the project can be retreived using $(oc project -q).

  1. Push the resulting docker image onto the docker registry
$ docker push $(minishift openshift registry)/$(oc project -q)/image

Deploying in the cloud

Once built and pushed on the docker registry, we need to run and expose the docker image.

  1. Allow Openshift pods to see their peers (a must for session replication to work)
$ oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)
  1. Run the docker image into one container
$ kubectl run $(oc project -q) --image=$(minishift openshift registry)/$(oc project -q)/image:latest --port 8080
  1. Expose the deployment on port 80 for it to be accessible
$ kubectl expose deployment $(oc project -q) --type=LoadBalancer --port 80 --target-port 8080

Your clustered application should now be up and running, you can connect to Openshift GUI using $ minishift console. When done simply log in and manage your application!

Credits

Classes in the package org.example.tomcat.cloud.stream are taken from the JGroups-Kubernetes project. This project also served as inspiration for our implementation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 95.3%
  • Dockerfile 3.2%
  • Shell 1.5%