Sunday, January 18, 2015

Apache Stratos VM Cartridges

This is another part of A Series of Blog Posts on Apache Stratos Cartridges. We will go through VM Cartridges in this blog post. Please hit Apache Stratos Cartridges if you haven’t read it before.

Apache Stratos VM Cartridges

A VM cartridge is a virtual machine (VM) on an IaaS that has software components to interact with Apache Stratos.

Components of a VM Cartridge

A generic VM cartridge includes Operating System, Puppet Agent, Init Scripts as shown below;
Generic Cartridge.png
A base image or an AMI will contain all these components and the VM will be spawned from this base image. All the other softwares such as Cartridge Agent and Server Apps will be installed at runtime using configuration management tools like Puppet or Chef.

A fully configured cartridge includes Operating System, Puppet Agent, Init Scripts, Cartridge Agent, Server Apps, and any other Dependent Apps as shown below;
Fully Configured Cartridge.png
All the needed softwares are already installed in the base image. Nothing will be installed at runtime, hence cartridge instance will be ready for use as soon as the instance is spawned.

Lets go through each components.

Base Image

As mentioned above, a generic base image will contain OS, Puppet Agent and Init Scripts, a fully configured base image will contain OS, Puppet Agent, Init Scripts, Cartridge Agent, Server Apps, and any other dependent apps. Stratos will use the base image to spawn cartridge instances.

Hit Creating a Cartridge to learn how to create a base image in various IaaSes.

Puppet Agent

The job of the Puppet Agent is to talk with Puppet Master periodically and configure itself according to Puppet Master’s instructions. Hit Puppet Labs to learn about puppet.

Init Scripts

It will start the Puppet Agent at the instance startup, so that Puppet Agent will connect to Puppet Master and do the node configuration.

Cartridge Agent

Cartridge Agent is a component that resides within a cartridge instance and handles the communication between the cartridge and Stratos. Hit Cartridge Agent for more information.

Server Apps

These are your applications such as Tomcat, PHP, MySQL, Wordpress, Ruby etc which you want to run on top of Stratos.

Dependent Apps

These are any apps which are needed for your Server Apps.

Puppet Master

Puppet Master contains all the puppet modules for cartridges.Hit Puppet Labs to learn about puppet.

Puppet Modules

Puppet Modules are self-contained bundles of code and data .Puppet master contains all the puppet modules for cartridges in Stratos. Hit How Cartridge Puppet Modules are organized in Apache Stratos? for more information.

Put it all together

Lets put all the components together and understand how cartridge works.
  • A cartridge deployer deploys a cartridge by giving details such as service name (a.k.a cartridge type), IaaS configuration details, base image id and the region where it resides, etc. Stratos will validate these information, update its in-memory and store these in the registry. 
  • A cartridge subscriber comes and subscribe to a cartridge. Stratos will spawn a new instance using the base image. In addition Stratos will send a payload with some information such as server name, puppet master name and IP, cluster id and so on. 
  • When a new VM (cartridge instance) is started, the Init Script will be executed at the instance boot up. This Init Script in turn will start the Puppet Agent. 
  • Meanwhile, Stratos will set the hostname of the new VM to a random string with service name as substring. 
  • When the Puppet Agent is started, it will talk with Puppet Master. Puppet Master has instructions about how each nodes should be configured. To be more specific, it has instructions about how each cartridge instance of a particular cartridge (service type) to be configured. Puppet Agent will configure the cartridge instance according to what is defined in Puppet Master for its service name by string matching the hostname. 
  • Once Puppet Agent configures everything successfully, Cartridge Agent within cartridge instance will start to communicate with Stratos. At one point, it will publish instance activated event to message broker. Thereafter this cartridge instance will be considered as an active instance and ready to accept traffic.
That is an end-to-end process from cartridge deployment to subscription to instance creation to instance configuration to instance activation.

Next thing to do

Now you have learned about VM Cartridges. Hit How to create a VM Cartridge? if you want to create a VM Cartridge. Hit Apache Stratos Docker Cartridges if you want to learn about Docker Cartridges.

References

Tuesday, January 13, 2015

A Series of Blog Posts on Apache Stratos Cartridges

Are you looking for a way to start contributing to Apache Stratos? You hit the right page!

The best way to start contributing to Apache Stratos is through developing and testing Cartridges. As I found there are not much useful guides for Stratos cartridge developers, I am writing a series of blog posts on Apache Stratos Cartridges to help those who wish to contribute to Apache Stratos. You will be able to contribute a good quality cartridge to Apache Stratos project by following this blog series.

Blog 5 - How to create a Docker Cartridge?

I will add some more advanced topics to this series later. If you want any specific topic on Apache Stratos Cartridges, feel free to leave a comment here.

Apache Stratos Cartridges

Apache Stratos

Apache Stratos is a highly-extensible Platform-as-a-Service (PaaS) framework from the Apache Community that anyone can use to build a foundation for multiple flavors of Platform as a Services such as Application PaaS (aPaaS), Integration PaaS (iPaaS), or Data PaaS (dPaaS). You should be clear that Stratos is not a PaaS, but can be used to build a PaaS. You can deploy Stratos on top of an IaaS and deploy any application such as Application Servers, Enterprise Service Buses, API Managers etc, on top of Stratos. Stratos takes care of your applications and provides features such as load balancing, auto-scaling, cloud bursting, multi tenancy, billing, monitoring, fault handling and much more.

Please visit Apache Stratos website for more information.

Cartridges

Stratos manages applications using cartridges. A cartridge is a virtual machine (VM) or a Container on an IaaS that has software components to interact with Apache Stratos. For example, a Tomcat cartridge is a Ubuntu virtual machine on Amazon EC2 IaaS with Tomcat server environment (Java + Tomcat) installed.  
 
All cartridges in Apache Stratos provide a very secure, OS level isolated environment for cloud applications. If you subscribe to a cartridge you will get a cartridge instance.

Cartridge Instances

If you subscribe to a cartridge, Stratos will spawn a new VM or Container on an IaaS, and that new VM or Container will be referred to as Cartridge Instance in Stratos terminology.

Cartridge Types

According to the mode of operation, cartridges can be divided into single tenant or multi tenant cartridges. According to the creation methods, cartridges can be divided into generic or fully configured cartridges. According to the virtualization technology, cartridges can be divided into VM or Docker cartridges.

Single Tenant Cartridges

In Apache Stratos, if a tenant user subscribes to a single tenant cartridge, a separate cartridge instance will be spawned for each tenant user. Thereby, single tenant cartridges provide tenant users process level isolation and instance level dedicated tenancy. Single tenant cartridge users can be mapped to one or more cartridge instances.

Multi Tenant Cartridges

Multi-tenant cartridges in Apache Stratos are cartridges that allow multiple tenants to share a single cartridge instance. Although tenant users share a single cartridge instance, the tenant user traffic will be securely directed to isolated application code within the cartridge instance.

Generic Cartridges

A generic cartridge is a cartridge where all the software needed for the cartridge instance are installed only at run-time when a cartridge instance is spawned. It only have the base image operating system (OS) and Puppet Agent (PA) pre-installed with some setup scripts. For example, a generic VM cartridge looks like below;

Fully Configured Cartridges

A fully configured cartridge also known as a pre-configured cartridge is a cartridge where all the software and configurations are pre-configured. Fully configured cartridges include the base image operating system (OS), setup scripts, required software, Puppet Agent (PA) and Cartridge Agent (CA). For example, a fully configured VM cartridge looks like below;
Fully Configured Cartridge.png 
Generic cartridges are slower than fully configured cartridges since all the software will be installed and configured at runtime.

VM Cartridges
A VM cartridge is a virtual machine (VM) on an IaaS that has software components, such as puppet agent, cartridge agent, server apps and any dependent apps, to interact with Stratos.

Please refer Apache Stratos VM Cartridges for more information.

Docker Cartridges

As per now, a Docker cartridge is a container on a coreos cluster configured on an IaaS that has software components, such as cartridge agent, server apps and any dependent apps, to interact with Stratos.

Please refer Apache Stratos Docker Cartridges for more information.

Next thing to do
Now you learned something about Apache Stratos Cartridges. If you are willing to learn more about VM Cartridges, please refer Apache Stratos VM Cartridges. If you are willing to learn more about Docker Cartridges, please refer Apache Stratos Docker Cartridges.