Skip to content

Commit

Permalink
Add support for restructured tomcat-in-the-cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-beck committed Dec 12, 2017
1 parent bff880c commit cc3c286
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 59 deletions.
6 changes: 3 additions & 3 deletions tomcat-in-the-cloud-pathway.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"title": "Introduction to Tomcat in the cloud",
"description": "Learn Tomcat in the cloud",
"title": "Introduction to Tomcat-in-the-cloud",
"description": "Learn Tomcat-in-the-cloud",
"paid": false,
"courses": [
{
"course_id": "deploy-titc-using-cli",
"title": "Deploy tomcat-in-the-cloud to OpenShift using CLI",
"title": "Deploy Tomcat-in-the-cloud to OpenShift using CLI",
"description": ""
}
]
Expand Down
23 changes: 23 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli/1_buildDependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
In order to function properly, _Tomcat-in-the-cloud_ needs a member provider that will essentially discover all running instances of Tomcat in the cloud environment. Currently, we developed a member provider that works for _Kubernetes_ and _OpenShift_ called **CloudMemberProvider**. We plan on extending that list by providing support for more cloud services in the near future.

_Tomcat-in-the-cloud_ also needs a way to establish connection throughout the cloud network so the HTTP requests can be sent to the right instances of the cluster. To do that, it depends upon another library that we call **CloudStreamProvider**. Stream providers can use a variety of different types of connections. We currently support unsecured and secured (via token) connections.

The first step is therefore to build these dependencies. **It's important that you follow the building order described bellow** as those dependencies depend on each other.

## A) Building CloudStreamProvider
*Clone the CloudStreamProvider repository :*

`git clone https://github.com/maxime-beck/cloudStreamProvider.git`{{execute}}

*Run the building process using Maven :*

`mvn -f cloudStreamProvider/pom.xml install`{{execute}}

## B) Building CloudMemberProvider
*Clone the CloudMemberProvider repository :*

`git clone https://github.com/maxime-beck/cloudMemberProvider.git`{{execute}}

*Run the building process using Maven :*

`mvn -f cloudMemberProvider/pom.xml install`{{execute}}
43 changes: 0 additions & 43 deletions tomcat-in-the-cloud/deploy-titc-using-cli/1_deployment.md

This file was deleted.

66 changes: 66 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli/2_deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
OpenShift has the concept of "projects". These projects allow you to group components of a system together without interfering or conflicting with other deployments on the system.

Using projects can make the management of large scale deployments much simpler. Instead of seeing all the applications deployed, you can focus your view depending on what you are trying to achieve. If required, it is still possible to see all deployed components at once.

## Setting up the environment
*Log into OpenShift :*

`oc login localhost:8443 --username=admin --password=admin --insecure-skip-tls-verify=true`{{execute}}

*We'll call this project "tomcat-in-the-cloud" :*

`oc new-project tomcat-in-the-cloud`{{execute}}

With the project created, the CLI context switches to the project. It is possible to change projects, or contexts, at any time.

The command `oc projects`{{execute}} lists all projects and `oc project <project-name>` allows you to switch projects if needed.

Add the permission so each pod can read the list of other tomcat-in-the-cloud pods :

`oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)`{{execute}}

## Deploying the web application
We created a simple rest clusterised counter demo to test how it operates in the cloud environment.

*Clone the demo from github :*

`git clone https://github.com/web-servers/tomcat-in-the-cloud.git`{{execute}}

Then simply build and deploy it using maven

`mvn -f tomcat-in-the-cloud/pom.xml fabric8:deploy`{{execute}}

## Monitor the execution
### *Using the command line*
*Check the pods :*

`oc get pods`{{execute}}

*Check the host (route) to access the application :*

`oc describe routes`{{execute}}

> The attribute *Requested Host* provides the URL to access your application.
*Scale the application to 3 pods :*

`oc scale dc tomcat-in-the-cloud --replicas=3`{{execute}}

### *Using the graphical user interface (GUI)*
*Access the GUI :*
- Select the **Dashboard** view at the top of the screen, you'll get redirected to the OpenShift GUI
- Login with your username/password (**admin/admin** in this scenario)
- Select the project named "tomcat-in-the-cloud"

*Check the pods :*
- Go to **Applications > Pods** to list them
- Select them to display their detailed information (Status, Used volumes, Containers, etc.)

*Check the route the access the application :*
- Go to **Applications > Routes** to get a list of the routes related to your applications
- Click on your application's **Hostname** to display it

*Scale the application to 3 pods :*
- Go to **Applications > Deployments**
- Select the deployment configuration you'd like to edit and select the **latest** deployment
- In the **Details** section, use the arrows to increase or decrease the number of running pods
5 changes: 2 additions & 3 deletions tomcat-in-the-cloud/deploy-titc-using-cli/env-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ yum install java-1.8.0-openjdk-devel.x86_64 -y > /tmp/toto.txt
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

# Installing maven
wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
wget https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.tar.gz
tar xvf apache-maven-3.5.0-bin.tar.gz
mv apache-maven-3.5.0 /usr/local/apache-maven
export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

11 changes: 7 additions & 4 deletions tomcat-in-the-cloud/deploy-titc-using-cli/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
"details": {
"steps": [
{
"title": "Step 1 - Deployment",
"text": "1_deployment.md"
}
"title": "Step 1 - Building Dependencies",
"text": "1_buildDependencies.md"
},
{
"title": "Step 2 - Deployment",
"text": "2_deployment.md"
}
],
"intro": {
"courseData": "env-init.sh",
"code": "set-env.sh",
"text": "intro.md"
},
Expand Down
4 changes: 3 additions & 1 deletion tomcat-in-the-cloud/deploy-titc-using-cli/intro.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
In this scenario, you will learn how to deploy Tomcat in the cloud 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, OpenShift, AWS and Azure.

In this scenario, you will learn how to build, deploy and monitor it in OpenShift.
14 changes: 9 additions & 5 deletions tomcat-in-the-cloud/deploy-titc-using-cli/set-env.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
~/.launch.sh

# Install jdk
yum install java-1.8.0-openjdk-devel.x86_64 -y
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

# Installing maven
wget http://www.pirbot.com/mirrors/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
tar xvf apache-maven-3.5.0-bin.tar.gz
mv apache-maven-3.5.0 /usr/local/apache-maven
# Installing Ant
yum install ant -y

# Installing Maven
wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
tar xvf apache-maven-3.5.2-bin.tar.gz
mv apache-maven-3.5.2 /usr/local/apache-maven
export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

0 comments on commit cc3c286

Please sign in to comment.