[Tutorial] Adding a Cartridge to Stratos
- Udara Liyanage
- Software Engineer - WSO2
Introduction
Before creating the cartridge, puppet master has to be configured by using the following link; Apache Stratos Puppet Master setup guide
Live terminal recording of configuring a puppet master can be found through the link; live terminal recording of setting up
Let’s assume, the puppet master was configured with the values,
PUPPETMASTER-DOMAIN= puppet.udara.com
PUPPET-MASTER-IP=192.168.18.13
Adding a cartridge to Stratos
- Create an ubuntu VM in Openstack
- Select the image with the OS and click Launch
- This will lead to a popup window called Launch instance where the Flavor has to be selected
- Choose a key pair
- Log in to the machine created via SSH
- Install unzip
- Create the configuration script in the path; /root/bin/config.sh with the content copied from this configuration file.
- Create the init script in /root/bin/init.sh with the content at this init script.
Copy and paste the content.
Make the script executable
chmod +x /root/bin/init.s
- Create the puppet-install script in /root/bin/puppetinstall/puppetinstall with the content at this script.
- Create the configuration file /root/bin/stratos_sendinfo.rb with the content of stratos_sendinfo.rb
- Now execute the config.sh
- Create the Snapshot
ssh -i udara.pem [email protected]
sudo apt-get install unzip
This step is carried out to extract the Stratos Cartridge Agent before installing the Cartridge Agent
vim /root/bin/config.sh
Copy the content.
Make the script executable
chmod +x /root/bin/config.sh
This script installs the service you want (PHP in this case) and install and start the Puppet agent. Then puppet agent connects to puppet master and installs the other required software such as Apache2, PHP, Java and Stratos cartridge agent, etc.
vim /root/bin/puppetinstall/puppetinstall
Copy and paste the content
Make the script executable
chmod +x /root/bin/puppetinstall/puppetinstall
cd /root/bin
./config.sh
For the questions prompt in this step should be answered with the following values;
Since we are going to make a PHP cartridge
service-name=php
As we set up the puppet master in the machine which has the IP address of192.168.18.134
puppet master IP=192.168.18.134
As we setup the puppet master with the hostname
puppet master hostname = puppet.udara.com
root@udara-cartridge:~/bin# ./config.sh
This script will install and configure puppet agent, do you want to continue [y/n]y
--2014-04-01 04:04:52-- https://169.254.169.254/latest/user-data
Connecting to 169.254.169.254:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-04-01 04:04:52 ERROR 404: Not Found.
Please provide stratos service-name:php
Please provide puppet master IP:192.168.18.134
Please provide puppet master hostname [puppet.stratos.org]:puppet.udara.com
This process may take some time. You may have to wait, till the process complete.
A log similar to below will be seen, once the above process is completed.
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 2367.76 seconds.
Now the machine is ready to become a cartridge. Required software is installed and configurations have been completed.
Click on Create Snapshot button
Save snapshot with a preferred name
Snapshot is waiting to be created
When the snapshot creation is completed, click on the snapshot to find details about it. The most important information is the ID of the image (snapshot).
When a PHP runtime is required, the user has to subscribe to a PHP cartridge in Stratos. When a PHP cartridge is subscribed, behind the scene, Stratos creates an instance from the image ID retrieved earlier. Since PHP is already installed and configured at the snapshot creating stage, PHP runtime will be available when Stratos spawn an instance from that snapshot.
Deploy the cartridge JSON in Stratos
Below is the cartridge JSON which is need to be deployed in Stratos. It is notable that the image ID is same as the snapshot ID, created above.
{ "type": "php", "provider": "apache", "host": "udara.com", "displayName": "PHP", "description": "PHP Cartridge", "version": "5.0", "multiTenant": "false", "portMapping": [ { "protocol": "http", "port": "80", "proxyPort": "8280" }, { "protocol": "https", "port": "443", "proxyPort": "8243" } ], "deployment": { }, "iaasProvider": [ { "type": "openstack", "imageId": "RegionOne/ac859fc9-d0dc-4f4fb084-bada02ad5129", "maxInstanceLimit": "5", "property": [ { "name": "instanceType", "value": "RegionOne/4" }, { "name": "keyPair", "value": "stratos-s4" } ] } ] }
Please refer to the cartridge deployment guide of Stratosfor more information.