Wednesday, December 2, 2015

Pre-Configured Apache Stratos VirtualBox Image for Your POC


Pre-Configured Apache Stratos VirtualBox Image for Your POC


Apache Stratos is a highly-extensible Platform-as-a-Service (PaaS) framework that helps run Apache Tomcat, PHP, and MySQL applications and can be extended to support many more environments on all major cloud infrastructures. For developers, Stratos provides a cloud-based environment for developing, testing, and running scalable applications. It providers benefit from high utilization rates, automated resource management, and platform-wide insight including monitoring and billing.

If you want to use apache stratos, first need to setup a IaaS layer using open source software like "openstack" or else you can setup stratos in amazon EC2. In this blog I'm providing you a pre-configured "Oracle Virtual Box" Image which include "openstack havana edition (IaaS)" with docker driver and "Apache Stratos". Further, there are more tools which describes later in this blog.


1.0 Introduction


The virtualbox image comes with this blog, is a VM image in “.ova” format which is an open format for hypervisors. But, the images is tested only with Oracle Virtual Box visualizer. The purpose of this vm image is to provide a testing environment for PaaS developers who uses “Apache Stratos” in the evaluation purposes as well as for demo activities.
Since it is difficult and time consuming task for new developers to setup apache stratos in their own development environment, this image enables them to quickly have a practical experience by quick setup.
This image consists of IaaS + PaaS + Sample Cartridge combination and includes the following main tools and middle-wares as a bundle.

- OpenStack installed using devstack (works as the underlying IaaS)
- Docker Container (works as the linux container for OpenStack)
- Apache Stratos (works as the PaaS)
- Docker Cartridge Images (work as the cloud instances)
- GitBlits (work as local git repository manager)
- MySql (RDBMS for OpenStack and Stratos)
- Active MQ and RabbitMQ (massege brokers for IaaS and PaaS)
- Apache Load Balancer (LB for PaaS)
- Java 1.7 (as jvm)
- Maven (as the build tool)

The configured virtualbox image could be downloaded from here : Download Stratos Image



2.0 Internal Structure of the Image

The internal structure of the Stratos Image is illustrated in the following picture.












Openstack with Docker work as the underlying IaaS. Apache Stratos work as the PaaS working with IaaS. On top of this stack, fully-configured cartridge images for “MySQL”, “PHP” and “Tomcat” have been configured as samples.


3.0 Installation Location and Configuration Data

The vm image comes as a fully configured PaaS environment. The installation directories of various components are as follows.

Devstack : /home/stratos/workspace/devstack
Stratos Source : /home/stratos/workspace/stratos
Java : /home/stratos/tools/java/jdk
Maven : /home/stratos/tools/build/maven
GitServer : /home/stratos/tools/gitserver/gitblit
Git Local Repo : /home/stratos/workbench/git-local-repo
Cartridge Builds : /home/stratos/workbench/cartridges
Cartridge Definition Files : /home/stratos/workbench/cartridge-definitions

Stratos Installation : /opt/stratos/apache-stratos-default
Stratos Installer : /opt/stratos-installer
Active MQ : /opt/stratos/apache-activemq-5.9.1
Load Balancer : /opt/apache-stratos-load-balancer-4.0.0


the following user credentials and urls of main services are required when setting up the vm image.


3.1 User Credentials

cNO
Tool/Component
UserId
Password
1
OS (Ubuntu 12.04)
root
password


stratos
password
2
OpenStack
demo
password


admin
admin
3
Stratos
admin
admin
4
GitBlits
admin
admin
5
Load Balancer
admin
admin
6
Active MQ
admin
admin
7
Cartridge Instances
root
password




3.2 URLs of Main Services





4.0 Installation Guide
The PaaS image comes as an “Appliance for VirtualBox”. The users need to import the image to Oracle Virtual Box software and setup the image in order to have a complete PaaS environment. Please, follow the steps below to setup the image.


4.1 Quick Start Steps

  1. Install and setup Oracle Virtualbox Hypervisor in your test machine.
- can be downloaded from : https://www.virtualbox.org/
- installation details can be found : https://www.virtualbox.org/manual/ch02.html
- minimum resource requirement would be 8GB memory, 4 cpus and 200GB hard   disk space.
  1. Create two “host-only” adapters named as “vboxnet1” and “vboxnet2” as per the images below.

Figure 4.1: Adding Host-only Network Interfaces

Figure 4.2: vboxnet1 Adapter Settings



Figure 4.3: vboxnet2 Adapter Settings

  1. Import the vm image to virtualbox as an appliance using “Import Appliance” feature as illustrated.
Figure 4.4: Import VM Image


  1. During the import process you can customize vm settings like memory, no of cpus etc.
Figure 4.5 : VM Settings

  1. Start the vm and login to OS with “stratos” userId.

  1. Start GitBilt Server : bash /home/stratos/tools/gitserver/gitblit/gitblit.sh

Figure 4.6 : Start Git Server




  1. Login to GitServer management UI with “admin” userId and check 2 sample repositories are present.

Figure 4.7 : Login to Git Server



Figure 4.8 : Git Sample Repositories

  1. Check Docker is running : service docker status

  1. Start OpenStack with DevStack :
bash rejoin-stack.sh

Figure 4.9 : Start OpenStack Services

  1. Make sure cartridge images are there in glance already :
    1. cd /home/stratos/workspace/devstack
    2. . openrc admin admin
    3. glance image-list [ make sure “mysql-cartridge:latest”, “php-cartridge:latest” and “tomcat-cartridge:latest” images are present]


  1. Login to OpenStack management UI with “demo” userId and make sure that it works.
 
Figure 4.10 : Login to OpenStack

  1. Start the Active MQ :  
sactivemq start

Figure 4.11 : Start Active MQ Server


  1. Start Stratos LB (use if you need to test lb with cartridge instances) :
bash /opt/apache-stratos-load-balancer-4.0.0/bin/stratos.sh

Figure 4.12 : Start Stratos Load Balancer


  1. Start Stratos :
bash /opt/stratos/apache-stratos-default/bin/stratos.sh

Figure 4.13 : Start Stratos PaaS




  1. Login to Stratos with given credentials and url and check whether it has started successfully.

Figure 4.14: Login to Stratos


  1. Stratos server logs can be monitored in the location :
/wso2carbon.log

Figure 4.15: Stratos Server Logs


  1. Go to the cartridges list of the stratos and click on the required cartridge to subscribe to it as illustrated below.

Figure 4.16: My Cartridges


Figure 4.17: Pre-Configured Cartridges to be Subscribed
  1. Subscribes to the cartridges you want by clicking on it.

  1. Sample cartridge subscription is illustrated below for “php” cartridge.

    1. Click on “PHP-7” cartridge and fill the details as below.

Figure 4.18: PHP Cartridge Definition
    1. Repo URL can be obtained from GitBlits Server’s sample php repo.

Figure 4.19: Sample PHP Application Repository in GitBlits Server
    1. Click on the “Subscribe to Cartridge” button after filling the data. Then, wait about 1-2 minutes and check the stratos log file (wso2carbon.log) until a cartridge instance is activated. (wait till the message “Member activated”) message is appeared.

Figure 4.20: Cartridge Instance Creation Logs in Stratos Log file


    1. Check the “PHP Cartridge” details page till the “ActiveInstances” count is 1.
Figure 4.21: PHP Cartridge Details


    1. Then check the spawned instance in openstack UI as well as illustrated below.

Figure 4.22: Spawned PHP Cartridge Instance in OpenStack


    1. Access the Sample PHP application deployed in the newly created cartridge with the URL : http://<member-public-ip>/ (e.g : http://192.168.92.1/) (default port is 80)
(The assigned IP address can be obtained from relevant cartridge details page of stratos UI.)

Figure 4.23: Deployed Sample PHP Application


  1. Similarly, you can subscribed to sample “Tomcat-7” and “MySQL 5.5” cartridges as well. The Sample application could be accessed after deployed with the following urls.

Figure 4.24: Sample MySQL Admin Application
URL : http://<member-public-ip>/ (default port is 80)


Figure 4.25: Sample Tomcat Application
URL : http://<member-public-ip>:8080/sample-app (default port is 8080)


  1. After creating all 3 cartridges, the “My Cartridges” would be as below. After playing around the cartridges you can unsubscribed to cartridges by clicking on the red color buttons.

Figure 4.26: Subscribed Cartridges


  1. The configuration files for sample cartridges could be found in the following urls.



5.0 Limitations

The vm image uses devstack to set up openstack environment. but, devstack has some limitations since it has developed only for creating testing environments. When the cartridges are unsubscribed, usually the instances spawned inside docker should be terminated and when subscribe again, new docker instance would be spawned. But, with the current setup of devstack with docker doesn’t terminate instances properly. Sometimes it is not possible to terminate instances in openstack manually too. Hence, it is not recommended, to go in the cycles of subscription and unsubscription of cartridges.
When users wants to go in testing cycles of subscription and unsubscription of cartridges, this setup is not recommended. After few cycles it is better to remove all the docker containers manually using docker client or reinstall devstack using “.stack.sh” script.


6.0 Summary
As described in the document, the “Stratos PaaS Image” is ready to run pre-configured PaaS image which could be run in less than 30 minutes. This allow new PaaS developers to evaluate and play with running apache stratos environment. Further, the image could be used as a demo tool to demonstrate a PaaS environment with “OpenStack”, “Docker”, “Stratos” and “GitBlits” like open source cloud tools.