Friday 25 April 2014

Apache Stratos PaaS simple setup

Introduction

This blog is for developers and administrators who are familiar with the upcoming Apache Stratos 4.0 (incubating) PaaS framework, who would like to try Stratos but don't have the time to go through the manual setup process.

This blog uses Vagrant to automate an environment for you to try out Stratos.  By following just a few steps, these are the things that are automatically done for you:

  • downloading a basic Ubuntu image for Virtualbox
  • start up the image 
  • set up up a Puppet Master
  • checkout, compile and install Stratos
  • set up OpenStack
  • create a Stratos Cartridge
  • set up eclipse with the Stratos source code

When following this blog, you will use shell scripts that I have created for Vagrant to set up the environment.  Later in the blog when using the scripts, feel free to have a look at the scripts to see what they are doing: hopefully, they should be understandable.  Also worth mentioning is that although Vagrant is used in this blog, you don't need to know anything about Vagrant - you will be shown all you need to know.

Note:
  • The machine running Virtualbox is the 'vagrant host', or just 'host'
  • The image running inside Virtualbox is the 'vagrant guest', or just 'guest'
  • OpenStack uses Qemu emulation to run instances which is very slow.  If you get a chance, head over to https://www.virtualbox.org/ticket/4032 and add a comment showing your support for Nested Virtualisation.  This will allow OpenStack to use KVM instead of Qemu which will be much quicker.

Prerequisites

You need at least 6Gb of free memory and around 30Gb free disk space on the 'host'. The setup should work on all of the platforms supported by Vagrant and Virtualbox.

This blog assumes you are connecting directly to the internet and not using a proxy server (unless that proxy server is transparent).  Proxy servers make it very difficult to setup an IaaS because each operating system instance will need to be configured to use the proxy server to have Internet access.

Install Vagrant and Virtualbox for your operating system.  Do NOT use the packages installed by your operating system (e.g. with apt-get), but instead install package from the following URLs:


Even if you already have Vagrant or Virtualbox installed, it may be worth installing the latest versions if yours are quite old. 

Note: if you hit any bugs with the environment described here, please raise an issue on the github project at: https://github.com/snowch/stratos-vagrant-box/issues

Setup steps

The vagrant project is stored in github.  If you have git installed, you can checkout using:
git clone https://github.com/snowch/stratos-vagrant-box.git
cd stratos-vagrant-box
git checkout v1.0
vagrant plugin install vagrant-cachier
Now all you need to do is run either:
new_dev_env_setup.bat (Windows users)
or
./new_dev_env_setup.sh (*nix users)
Then wait.  A lot of software is being downloaded and setup.  This can take quite a few hours to complete.  When the script has finished successfully, you should see:
...
Finished configuring the cartridge.
Note the cartridge id:  6bfe03f0-f725-456d-9ede-6af763f80528 
(your actual cartridge id will be different)

Warning: If you run the script again, it will delete your previous created guest, create a new guest and go through the whole installation process again.  If the script does not finish successfully the first time around, you can re-run the script to retry installing from scratch.

After successful completion of the 'stratos_developer_env_setup' script, you should be able to access the Stratos and OpenStack web consoles using:


You can get ssh access to the 'vagrant guest' by running the following command from the stratos-vagrant-box directory:
vagrant ssh
After ssh'ing into the 'guest', you will see the scripts used to setup your environment. stratos.sh and openstack-qemu.sh.  You can run these scripts with no arguments to see a list of options for each script.

For a graphical client, you can use 'rdesktop' if your host is a *nix variant, or 'Remote Desktop Connection' on Windows to connect to the 'guest'.  The connection details are:

  • Hostname: 192.168.56.5
  • Port: 3389 (not required if using Windows Remote Desktop Client)
  • Username: vagrant
  • Password: vagrant

After connecting with rdesktop or Remote Desktop Connection, scroll to the bottom left on the window and click on the Ubuntu desktop menu to open the Eclipse IDE.  When eclipse prompts you for the workspace location, accept the default.  Then click the icon to go to the Workbench.  You should now see the Stratos source code imported ready for you to hack. Note that hacking is optional - you can use the 'guest' just for  trying out the Stratos runtime.

If you are still inside the ssh session, type CTRL-D to exit, so you are back at the stratos-vagrant-box directory.  Run the command: 'vagrant halt'.  This will shutdown the virtualbox guest, ready for the next blog.

The next blog will describe how to use your vagrant guest, and will introduce commands to start, stop and remove your 'guest', and commands to start, stop and reconfigure Stratos and OpenStack inside the 'guest'.

4 comments:

  1. If you run hit the issue similar to this:

    Failed to read artifact descriptor for
    net.sf.saxon:saxon-xpath:jar:8.9: Could not transfer artifact
    net.sf.saxon:saxon-xpath:pom:8.9 from/to saxon-8.9-repo
    (http://mirrors.sunsite.dk/maven2): Connection timed out -> [Help 1]

    Run 'vagrant ssh' to ssh into your guest, then run:

    wget http://maven.wso2.org/nexus/content/repositories/wso2maven2/net/sf/saxon/saxon-xpath/8.9/saxon-xpath-8.9.jar

    mvn install:install-file \
    -Dfile=saxon-xpath-8.9.jar \
    -DgroupId=net.sf.saxon \
    -DartifactId=saxon-xpath \
    -Dversion=8.9 \
    -Dpackaging=jar \
    -DgeneratePom=true

    After that, try running the new_dev_env_setup.x script again.

    ReplyDelete
  2. Your welcome Wen. I'm glad you found it useful.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete