Last week I read a research paper called “Computer Immunology” written by a computer scientist Mark Burgess(Founder of CfEngine). Thanks to Solomon Hykes for referring about it in one of YC (Start-up Incubator Forum). I was heavily inspired by the idea of its writing which,as an analogy to Human Immune System, think about how systems, not just servers but whole systems, could be self-healing and the different scales from the small parts to the large scales. Though the research paper was published around 20 years ago, but interestingly the concept is getting rediscovered in the recent past when we talk about Cloud Immutable Infrastructure Pattern. In one of his recent interview, Mark pointed out an interesting statement –
“..Self-healing of machines was a good strategy at that time. In the future though, if you look at biology, there was also another strategy which is you have sufficient redundancy if you scratch a few skin cells off your arm, you don’t bleed, you don’t die. But in this world of hundreds of servers, if you lose a server it still means a lot.
Today, we’re actually approaching a sort of biological scale which we can argue in this way and this of course is what is happening in cloud with the immutable infrastructure pattern. Don’t repair, simply cast aside and build a new one and replace it.”
Inspired by this research paper, there has been rise of several products and tools for creating and managing declarative and self-healing infrastructure. “Infrakit” is a new toolkit which has recently been open sourced by Docker Inc. in last ContainerCon Europe 2016 held in Berlin, Germany. Last year, “Swarmkit” was introduced as a declarative management toolkit for orchestrating containers which got later integrated into 1.12 as “Swarm Mode”. This year, Docker Team focused on solving another difficult problem – Managing Docker on diverse Cloud Platform like AWS & Azure.
Why Infrakit?
In the recent past, Docker Team came up with various Docker editions like Docker for Mac & Docker for AWS or Azure, trying to make Docker work out-of-the-box and making updates easier, especially Docker for Mac just works great.But infrastructure Management in terms of AWS & Azure is still difficult. Reason – AWS architecture is inherently a distributed system which contains numerous subsystems having lots of moving parts like provisioning VPCs, EC2 instances setup, IAM roles, integration with CloudFormation etc. Before you run Docker containers, you need to setup all these infrastructure management functionalities beforehand in order to provide services to your end-user.
To solve the above problem, Docker Team came up with a solution in the form of toolkit called “Infrakit”. As it name suggests, Infrakit is a toolkit to create and manage infrastructure,that is scalable, self-healing and declarative in nature. Please remember that it is not a standalone tool, it’s a component designed to be embedded in a higher-level tool. What does this mean? One can use Infrakit to provision any kind of infrastructure using a custom “flavor”. This is expected to be integrated into Docker 1.13 for built-in infrastructure management(just like the story of “SwarmKit”)
Defining Infrakit
Infrakit is defined as “Declarative”, “Self-healing” & “Scalable”. Let us spend some time in understanding what it actually means. By declarative, it means that the toolkit rely on JSON schema configuration for the user to describe the infrastructure state. JSON is used for configuration because it is composable and a widely accepted format for many infrastructure SDKs and tools. Since the system is highly component-driven, the JSON format follows simple patterns to support the composition of components.
Talking about “Self-Healing” aspect, it is different from other traditional configuration management tools(like Puppet, CFEngine). Infrakit comprises of whole network sets of active process(called as plugins) which collaborate with each other to analyze and perform action to bring infrastructure in the desired state.These processes are always busy in continuously monitoring the infrastructure to take any kind of state divergence. Based on the state divergence, it decides on the necessary actions. It is continuously monitoring and reconciling the actual state against the specification. This is also valid for rolling updates which is seamless without disturbing the running services.
How does Infrakit Plugins Work?
InfraKit uses Plugins, which are active processes and the only building block to manage infrastructure. Technically, a Plugin is an HTTP server with a well-defined API, listening on a UNIX socket.Currently there are three kind of plugins (also called as Utilities) supported by Infrakit which represents different layer of abstraction representing whole stack of infrastructure, namely – Flavors, Group and Instance.
Group: InfraKit provides primitives to manage Groups plugins which are for managing cluster of machines. These clusters comprises of either cattle (machines with identical configs) or pets(machines with different configs)
Flavors: A Flavor Plugin can be thought of as defining what runs on an Instance. It basically helps in distinguishing members of one group from another by describing how these members should be treated. Flavors allow a group of instances to have different characteristics. In a group of cattle, all members are treated identically and individual members do not have strong identity. In a group of pets, however, the members may require special handling and demand stronger notions of identity and state.
Instance: Instances are members of a group. An instance Plugin manages some physical resource instances. It knows only about individual instances and nothing about Groups. Instance is technically defined by the plugin, and need not be a physical machine at all.For compute, for example, instances can be VM instances of identical spec.
To deep dive into Infrakit architecture, I recommend reading this.
Test-Driving the Infrakit:
To test drive Infrakit in just 5 minutes, I created a Docker image “ajeetraina/infrakit” which is a Ubuntu 16.04 based image with required GO package and build system ready to use. Let’s use this Docker image to illustrate how Infrakit performs self-healing operation.
Login into one of your Docker host machine and run the container as shown below:
First, we will execute the below command to start the File instance plugin:
Next, we will start a group plugin in the new terminal as shown below:
Then, it’s time to start one of the provided flavor plugins called ‘vanilla’, which will be used to create a group.
In addition to default Instance File Plugin, let’s start another File Instance plugin as shown:
We need to create JSON based configuration file to give it to the Group plugin:
cat << EOF > collabnix.json
{
“ID”: “collabnix”,
“Properties”: {
“Allocation”: {
“Size”: 5
},
“Instance”: {
“Plugin”: “collabnix-instance-file”,
“Properties”: {
“Note”: “Collabnix Infrakit 101”
}
},
“Flavor”: {
“Plugin”: “flavor-vanilla”,
“Properties”: {
“Init”: [
“docker pull dockercloud/hello-world”,
“docker run -d -p 8080:80 dockercloud/hello-world”
],
“Tags”: {
“tier”: “web”,
“project”: “infrakit”
}
}
}
}
}
EOF
This Docker image is already equipped with this file under collabnix directory under Infrakit base directory. Hence, the below commands should work great as expected.
By now, you must see the below command showing the right output:
Let’s execute the below command to keep a close watch over collabnix group.
Under Infrakit-group-plugin, you will find some actions for group “collabnix” where 5 instances of dockercloud/hello-world is ready.
Also, you can inspect “collabnix” group as shown below:
Cool, Isn’t it?
Let’s test the “Self-Healing” aspect now. As we see below, there are number of instances running.
Let us remove few of those instances to see if it actually spun up well:
Wow ! Self-Healing aspect just worked well. Meanwhile, we can check the output at group instance:
This is just one operation with Infrakit. Infrakit is currently under active development and there are lots of further exciting stuffs coming up. In the future post, I am going to see how it integrates under Swarm Mode. Keep Reading !
[clickandtweet handle=”@ajeetsraina” hashtag=”#Infrakit” related=”@docker” layout=”” position=””]Infrakit Test-Drive & demonstration of Self-Healing Operation using Docker container[/clickandtweet]