Creating a Cartridge on EC2
The following sub-sections describe the steps involved in creating a cartridge on the EC2 IaaS:
Step 1 - Spawning an instance
Prerequisites
Prerequisite | Description |
---|---|
EC2 Account | To follow this guide, you need an EC2 account. Create an AWS account if you do not have an account. For more information, see Sign Up for Amazon EC2. This account must be authorized to manage EC2 instances (including start and stop instances, create security groups and key pairs). |
Create a security group | For more information, see Creating a security group. |
Create a key pair | For more information see Creating a key pair. |
Creating a security group
Before launching the instance, you need to create the right security group. This security group defines firewall rules for your instances, which are a list of ports that are used as part of the default Stratos deployment. These rules specify which incoming network traffic is delivered to your instance. All other traffic is ignored. For more information on the ports that should be defined, see /wiki/spaces/SM100/pages/14222781.
To create the security group and configure it:
- On the Network and Security menu, click Security Groups.
- Click on Create Security Group.
- Enter the name and description of the security group.
- Click Yes, Create .
- Click Inbound.
Select "Custom TCP rule".
- Enter the port or port range.
The /wiki/spaces/SM100/pages/14222781 section lists two kinds of ports, which are ports opened for outside access and ports restricted for internal access. You will have to ideally enter each of the ports as separate rules. Click Add Rule and then click Apply Rule Changes.
Always apply rule changes, as your rule will not get saved unless the rule changes are applied.
Repeat steps 6 to 8 to add all the ports mentioned, as each port or port range has to be added as a separate rule.Note down the names of your security groups if you wish to enter your user data in the wizard.
Creating a key pair
Before launching the instance, it is recommended to create a Key Pair. Save your private key in a safe place on your computer. Note the location because you will need the Key Pair to connect to your instance.
To create a Key Pair and download it:
- On the Network and Security menu, click Key Pairs.
- Click Create New Key Pair.
- Enter a name for your Key Pair.
- Click Create. After the Key Pair automatically downloads, click Close.
- Set the key pair permission as follows:
chmod 0600 <KEY_PAIR_NAME>
Spawning an EC2 Instance
- Sign in to the Amazon Web Services (AWS) Management Console and open the Amazon EC2 console.
- Click EC2 on the home console.
- Select the Region for the instance from the region drop down list.
Click Launch Instance.
Select Quick Launch Wizard.
Name your instance, for example 'StratosCartridgeInstance'.
- Select the key pair that you created.
Select More Amazon Machine Images and click on Continue.
- On the next page, specify the image .
- Click Continue.
- Click Edit Details.
- Edit the image size.
- Select the Instance Details option.
- Change the image type as required.
- Select a security group.
- Select the Security Settings option.
- Click Select Existing Security Groups.
- Select the security group you have created previously.
Click Launch to start the EC2 instance.
Click Close.
This will redirect you to the instance page. It takes a short time for an instance to launch. The instance's status appears as pending while it is launching. After the instance is launched, its status changes to running.
Step 2 - Configuring the cartridge
DevOps can create a cartridge either by using the quick guide or the detailed guide, as explained below:
Quick Guide
Follow the instructions below to configure a cartridge image for OpenStack or EC2. These instructions describe how to create a cartridge from an existing Debian/Ubuntu based Linux 12.04.1 LTS image as a quick guide.
Obtain a spawned instance in the respective IaaS to create a cartridge on top of it and start the image using EC2. For more information on how to spawn as instance in EC2, see step one above.
Use the complete set of instructions below to configure a cartridge image for WSO2 Private PaaS on Debian/Ubuntu based Linux 12.04.1 LTS distributions:
sudo -i apt-get install zip unzip mkdir -p /root/bin cd /root/bin wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/config.sh;hb=HEAD" -O config.sh chmod +x config.sh wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/init.sh;hb=HEAD" -O init.sh chmod +x init.sh mkdir -p /root/bin/puppetinstall wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/puppetinstall/puppetinstall;hb=HEAD" -O puppetinstall/puppetinstall chmod +x puppetinstall/puppetinstall wget "https://git-wip-us.apache.org/repos/asf?p=stratos.git;a=blob_plain;f=tools/puppet3-agent/stratos_sendinfo.rb;hb=HEAD" -O stratos_sendinfo.rb
Edit the
/root/bin/puppetinstall/puppetinstall
script to set the TIMEZONE value to match the timezone set on the Puppet Master.You can use the following command to set the timezone value. In this case we are setting the timezone to 'Etc/UTC':
sed -i 's:^TIMEZONE=.*$:TIMEZONE=\"Etc/UTC\":g' /root/bin/puppetinstall/puppetinstall
Execute the
config.sh
file and provide the stratos service-name
,puppet master IP
andpuppet master hostname
when prompted as follows:stratos service-name
- Enter one of the modules which are provided as templates in Stratos. For further details on the modules that can be used as values, see step 7(f) of Configuring Puppet Master. If you enter 'default
', a generic cartridge will be created.puppet master IP
- Enter the IP address of the machine on which Puppet Master is configured.puppet master hostname
- This should be identical to the output received when running thehostname
command. See step 5(b) of Configuring Puppet Master, for further details on executing thehostname
command.
This script will install and configure puppet agent, do you want to continue [y/N] y Please provide stratos service-name: php Please provide puppet master IP: 192.168.1.1 Please provide puppet master hostname [puppet.test.org]: puppet.test.org Node Id 076227021438.default.php Domain puppet.test.org Running puppet installation with arguments: -n076227021438.default.php -dpuppet.test.org -s192.168.1.1
Detailed Guide
Follow the instructions below to configure a cartridge image for OpenStack or EC2. These instructions describe how to create a cartridge from an existing Debian/Ubuntu based Linux 12.04.1 LTS image as a more detailed guide.
Obtain a spawned instance in the respective IaaS to create a cartridge on top of it and start the Ubuntu image 12.04.1 using your IaaS. For information on how to spawn as instance in EC2, step one above.
Navigate into your Ubuntu image using SSH and get root access.
sudo -iInstall zip.
apt-get install zip unzip
Navigate to the root directory.
cd /root
Create a new folder named
bin
in theroot/
directory.
mkdir bin
Create a
config.sh
file in the/root/bin/
directory, copy the configurations from theconfig.sh
file, and save the file .Make the
config.sh
file executable.chmod +x config.sh
Create an
init.sh
file in the/root/bin/
directory, copy the configurations from theinit.sh
file, and save the file.Make the
init.sh
file executable.chmod +x init.sh
Navigate to the
/root/bin/
directory.
cd/root/bin/
Create a new directory named
puppetinstall
in the/root/bin/
directory.mkdir puppetinstall
Create a file named
puppetinstall
in the/root/bin/puppetinstall/
directory, copy the configurations from thepuppet install
file, and save the file.Make the
puppetinstall
file executable.chmod +x puppetinstall
Create a file named
stratos_sendinfo.rb
inside the/root/bin/
directory . Copy the configurations from thestratos_sendinfo.rb
file and save the file.Execute the
config.sh
file and provide the stratos service-name
,p
uppet master IP
, andpuppet master hostnam
e when prompted as follows:stratos service-name
- Enter one of the modules which are provided as templates in Private PaaS. For further details on the modules that can be used as values, see step 7(f) of Configuring Puppet Master. If you enter 'default
', a generic cartridge will be created.puppet master IP
- Enter the IP address of the machine on which Puppet Master is configured.puppet master hostname
- This should be identical to the output received when running thehostname
command. see step 5(b) of Configuring Puppet Master, for further details on executing thehostname
command.
This script will install and configure puppet agent, do you want to continue [y/N] y Please provide stratos service-name: php Please provide puppet master IP: 192.168.1.1 Please provide puppet master hostname [puppet.test.org]: puppet.test.org Node Id 076227021438.default.php Domain puppet.test.org Running puppet installation with arguments: -n076227021438.default.php -dpuppet.test.org -s192.168.1.1
Step 3 - Repackaging the cartridge as a machine image
Follow the instructions below to repackage the cartridge as a machine image on EC2:
Open the Amazon EC2 console.
Make sure the appropriate Region is selected in the region selector of the navigation bar.
Click Instances in the navigation pane.
- On the Instances page, right-click your running instance and select Create Image.
Fill in a unique image name and an optional description of the image (up to 255 characters), and click Create Image.
In Amazon EC2 instance store-backed AMIs, the image name replaces the manifest name. For example,
s3_bucket/something_of_your_choice.manifest.xml
), which uniquely identifies each Amazon Amazon EC2 instance store-backed AMI.Amazon EC2 powers down the instance, takes images of any volumes that were attached, creates and registers the AMI, and then reboots the instance.
Go to the AMIs page and view the AMI's status. While the new AMI is being created, its status is
pending
.It takes a few minutes for the whole process to finish.
- Once your new AMI's status is
available
, go to the Snapshots page and get the Snapshot ID of the new snapshot that was created for the new AMI, that will be used in the Sample Cartridge Definition JSON file. Any instance you launch from the new AMI uses this snapshot for its root device volume.
After you finished creating the cartridge, make a note of the image ID you creates for the cartridge, as you will need this when you use Stratos Manager to deploy the cartridge. For more information on deploying the created cartridge using the Stratos Manager, see Deploying a Multi-tenant Service Cluster via the UI.