Yet Another Problem Statement(YAPS)…
Let us accept the fact – “Managing Docker on different Infrastructure is still difficult and not portable”. While working on Docker for Mac, AWS, GCP & Azure, Docker Team realized the need for a standard way to create and manage infrastructure state that was portable across any type of infrastructure, from different cloud providers to on-prem. One serious challenge is that each vendor has differentiated IP invested in how they handle certain aspects of their cloud infrastructure. It is not enough to just provision n-number of servers;what IT ops teams need is a simple and consistent way to declare the number of servers, what size they should be, and what sort of base software configuration is required. Also, in the case of server failures (especially unplanned), that sudden change needs to be reconciled against the desired state to ensure that any required servers are re-provisioned with the necessary configuration. Docker Team introduced and open sourced “InfraKit” last year to solve these problems and to provide the ability to create a self healing infrastructure for distributed systems.
InfraKit is basically a toolkit for infrastructure orchestration. With an emphasis on immutable infrastructure, it breaks down infrastructure automation and management processes into small, pluggable components. These components work together to actively ensure the infrastructure state matches the user’s specifications. InfraKit therefore provides infrastructure support for higher-level container orchestration systems and can make your infrastructure self-managing and self-healing.
Why the Integration of LinuxKit with Infrakit now??
LinuxKit is gaining momentum in terms of a toolkit for building custom minimal, immutable Linux distributions. Integration of Infrakit with LinuxKit will help users to build and deploy custom OS images to a variety of targets – from a single vm instance on the mac (via xhyve / hyperkit, no virtualbox) to a cluster of them, as well as booting a remote ARM host on Packet.net from the local laptop via a ngrok tunnel.
Under this blog post, I will show you how does InfraKit and LinuxKit work together to build immutable infrastructure. I want to test drive these toolkits on my macOS Sierra 10.12.3 system.
Copy the file to your path:
Infrakit is cross compiled and installed on your system. Let us try to see what playbook are available as of now.
Adding INFRAKIT_HOME variable:
bash-3.2$ source ./.bash_profile
bash-3.2$ echo $INFRAKIT_HOME
Adding LinuxKit Playbook
By default, there is no playbook available . Let us try to install LinuxKit and see how InfraKit integrate with LinuxKit.
Create a directory called testproj.
Add the LinuxKit Playbook:
Verifying the LinuxKit Playbook
Run the below command to see what options are available under LinuxKit playbook:
Installing HyperKit Plugin on your Mac
This command installs HyperKit plugins and add it under /usr/local/bin directory automatically.
Under the testproj directory, you will now see infrakit-instance-hyperkit gets created:
Installing Moby Build Tool to build custom OS images
Once it gets completed, you will see the options to build OS images:
Now the software has been installed. The Playbook has command to start everything.
Starting the LinuxKit
Ensure that you type “yes” for ‘Start HYPERKIT plugin’ while running the above command.
By now, the Infrakit command line interface will show additional options:
As you see above, CLI is contextual. It basically discovers the hyperkit plugin running and generates a new command for you to access it
In case hyperkit plugin is not turning up, you can kill the old hyperkit instance process and re-start it.
Verify if the hyperkit plugin is up and running
In case you want to run HyperKit, there is recommended command for it.
By now, we have everything ready for our LinuxKit SSH playbook
LinuxKit SSHD Example:
Now let me show you how to build a LinuxKit image containing just a simple sshd.The file `sshd.yml` defines the components inside the image. Instead of a standard LinuxKit image yml, it is actually an InfraKit template that is rendered before the moby tool is invoked to build the actual OS image.
This will show up the detailed information on its usage on your terminal:
Let us first build the “SSHD” YAML file using the below command:
Running the SSH Instance
Using the `hyperkit` subcommand (does not require billing accounts / signup on providers),you can create a single or a cluster of instances after you run the `build-image`.
The command `… hyperkit run-instance` will use hyperkit plugin to create a single guest vm that boots from the image you built with `build-image`.
This command brings up the LinuxKitOS instance.
Now you can run the below command to enter into SH shell
[ A Special Thanks to David Chung, Docker Team for assisting me understand LinuxKit Playbook thoroughly.]
In the future blog post, I will show you how LinuxKit + Infrakit + GCP works together.
Did you find this blog helpful? Feel free to share your experience. Get in touch @ajeetsraina.
If you are looking out for contribution/discussion, join me at Docker Community Slack Channel.
Know more what’s happening with Infrakit project activities clicking on this link.