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;
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;
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
- 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.
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
References