Skip to content

Commit

Permalink
Integrate cloud deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-beck committed Mar 19, 2018
1 parent 9b017b2 commit 2d34f33
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tomcat-in-the-cloud-pathway.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"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 - Stable",
"description": ""
},
{
"course_id": "deploy-titc-using-cli-latest",
"title": "Deploy Tomcat-in-the-cloud to OpenShift using CLI - Latest update",
"description": ""
}
]
Expand Down
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}}
70 changes: 70 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/2_deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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 clusterized 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
You can orchestrate your containers either via the command line or the graphical user interface
of OpenShift. The following sections will give you some instructions on how to monitor the execution
of your running application using both of these tools.

### *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
- Log in 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 to 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
14 changes: 14 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/env-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# test stuff
ssh root@host01 "> /tmp/toto"

# Install jdk
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 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 PATH=$M2:$PATH
1 change: 1 addition & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/finish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
More information can be found at https://docs.openshift.org/latest/dev_guide/builds.html
34 changes: 34 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"icon": "fa-openshift",
"title": "Deploying tomcat-in-the-cloud to OpenShift",
"description": "",
"pathwayTitle": "OpenShift",
"backend": {
"imageid": "openshift",
"port": 8443
},
"environment": {
"showdashboard": true,
"dashboard": "Dashboard",
"uilayout": "terminal"
},
"details": {
"steps": [
{
"title": "Step 1 - Building Dependencies",
"text": "1_buildDependencies.md"
},
{
"title": "Step 2 - Deployment",
"text": "2_deployment.md"
}
],
"intro": {
"code": "set-env.sh",
"text": "intro.md"
},
"finish": {
"text": "finish.md"
}
}
}
3 changes: 3 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_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.
16 changes: 16 additions & 0 deletions tomcat-in-the-cloud/deploy-titc-using-cli-latest/set-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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 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 PATH=$M2:$PATH

0 comments on commit 2d34f33

Please sign in to comment.