Earlier, I had written a blog on Docker Orchestration. This is a pretty new area and different solutions are being developed to address this problem. Few weeks back, I had written a blog on AWS EC2 Container service. Kubernetes is a Docker Orchestration engine used to manage a cluster of Containers. Google initially developed Kubernetes, currently its an open source project and source code is available here. Google Cloud’s Container engine uses Kubernetes to manage Docker Containers. Kubernetes can be used standalone or with any Cloud service like AWS, EC2.
Following are basic building blocks within Kubernetes:
- Cluster(master and minion) – This is the cluster of machines where Container services are launched on. There is 1 master node and the other nodes are called as worker nodes or minions. The master node runs etcd configuration database service, scheduler to schedule the containers, api server for external clients to talk to, replication controller to manage the state of containers. The minion node runs a slave agent to talk to the master node.
- Pods – can be a single container or a collection of containers. Containers within a pod share same characteristics and are brought up and teared down together. They are normally launched on same minion. An example could be a pod containing redis master and slave database containers. Pod configuration is defined as a json file.
- Service – Service is an abstraction over Pod that is useful for Service discovery and exposing environment variables to other services. Example could be a database service exposing port numbers to web service.
- Labels – Labels are used with Pods and Services for easier management of Containers through filters. Rather than managing individual Pods and Services, Containers can be managed at Label level. For example, we can say destroy all “frontend” labels.
Kubernetes can be used standalone and can work with any Cloud service like AWS, Google Cloud, Microsoft Azure. It can be used with CoreOS clusters as well as in baremetal. Kubernetes provides scripts to ease the creation of clusters and services that needs to be run in the master.
There are 2 options for using Kubernetes with Google cloud. First option is to install Kubernetes on Google compute engine VM and then use kubectl to manage it. The second option is to use the Google container engine service where Kubernetes is hidden underneath and we can use higher level abstraction to manage container cluster.
I found lot of similarities between AWS ECS Container service and Google’s Container Engine. AWS ECS does not use Kubernetes, they use their own scheduler. Amazon has mentioned that it would allow integration of other schedulers at a later point. Both are under preview stage currently. Docker is also working on a native clustering mechanism. Following are some generic steps for Container cluster management whichever solution we use:
- Create cluster of machines. Could be of same or different hardware configuration.
- Break the application into smaller micro-services and deploy the micro-services as containers into the cluster based on some defined constraints.
- Agents monitor the container lifecycle and these agents start running as part of cluster creation in the master node.
In the next 2 blogs, I will share the 2 approaches that I used for trying out Kubernetes, first using Google container engine and then using Kubernetes on Google compute engine VM.
I tried the Vagrant approach to create Cluster but that did not work since I am already running Ubuntu inside a Virtualbox and we cannot run 64 bit OS in nested virtualization scenario. Kubernetes script does not work from Windows.