Here are my notes from Marko Anastasov's talk in RuPy 2013 about virtualization and provisioning with LXC, Chef, and Docker.
- What would you do if you could make your own Heroku? Abstractions in programming languages, frameworks, APis. Dealing with hardware going in a similar direction: Virtualization, provisioning.
- Talk based on experiences from the Semaphore CI service. It's the first CI service to provide integration to GitHub. Running thousands of private builds a day now.
- What's a container? Explained a server virtualization approach that runs on an OS level. OS runs the kernel, runs virtual servers, "containers", in the user space. Assigns resources limitations and policies on CPU, memory. Different from full virtualization like VMWare, which is full emulation of the hardware, or paravirtualization like Zen. Both involve running multiple kernels - not so for containers. Containers have better performance because of that. Can provide high-speed computing services at acceptable prices. If you need to run code in isolation, containers are a good fit.
- LXC = Linux containers. Can be installed through apt, gives a bunch of command line tools for managing containers.
- lxc-create makes a container.
- It's really all just files in a directory. Bunch of configuration, and a rootfs dir which contains a full Linux installation.
- lxc-console lets you log into the container.
- When done, you can create a tarball and reuse it since it's all just files.
- More info in the Ubuntu server guide and lxc-users list.
How to put stuff to containers to make them useful?
- Chef - open source tool for specifying configuration. Basically a Ruby DSL. No need to be a rubyist to understand it.
- Infrastructure as source code.
- Specify the state you want the system to be in. Chef will do it deterministically and repeatedly. If already in the state, it will not do anything.
- Make a Chef recips, for, say installing some packages. Chef will install (or not if already there).
- Bundle of recipes, templates, metadata, makes a cookbook. That's how you distribute things in Chef. Lots of open source cookbooks you can study and reuse (opscode provides a lot).
- Chef tools: Client, server, data bags, knife... may be a bit overwhelming if you just want to run some scripts. Recommend to start with Chef Solo, a Ruby gem which lets you run without a full client-server thing.
- A minimal chef-solo setup made by Marko is available.
- Docker is a new kind of container technology. Tries to standardize a lot that's recommended in the previous part of the presentation. A repo of open source images you can use, similar to Ruby gems.
- Like an abstraction layer on LXC. Install Ubuntu, it creates an LXC container, then creates a UFS file system on top of the other file system. Lets you have shared, read-only areas for all running containers, saving space. Allocates a network interface with an IP address (you need to do much more low level work on this with bare LXC). Then runs your thing in a container as an "application".
- Important point: Docker should be used to run applications, and not entire systems. Example, Postgres, Redis, Memcached, Rails may be containerized as tiny, separate things. More portable than a DIY configuration.* Provides version control for container changes.
- Not quite production ready, as its makers say. You potentially expose yourself to a new layer of bugs.
- In theory, very portable, actually only works on Ubuntu though there are ports. There's a collaboration with Red Hat, making it run on RHEL. The side effect of this will be that it should run on any platform.
- What if I deploy a new version of the database container? How does the app learn about the new address? How do you deal with persistent data? Hopefully there will be tools to address these issues.
rails generate model Postto
docker run myapp production?
Know Your AngularJS Inside Out
Build Your Own AngularJS helps you understand everything there is to understand about AngularJS (1.x). By creating your very own implementation of AngularJS piece by piece, you gain deep insight into what makes this framework tick. Say goodbye to fixing problems by trial and error and hello to reasoning your way through them