Container Clustering tools and techniques


All the noise are around, the companies are moving their server applications from virtual machines (VM) to containers.

So why does everyone love containers?

Containers use shared operating systems. That means they are much more efficient than hypervisors in system resource terms. Instead of virtualizing hardware, containers rest on top of a single Linux instance.  Among other benefits, containers offer a software architecture that provides portability and managed distribution of software assets. This has caused enterprises and software vendors to embrace container technology as they prepare for cloud.

But despite their success, containers still present challenges. Container scalability, for example, remains somewhat of a mystery. Some organizations struggle when trying to scale Docker, one of the leading container technologies.

There are couple of Open Source container cluster management tool. Each cluster management technology has something unique and different to offer.

  • Apache Mesos is mature and can also run non-containerized workloads (such as Hadoop).
  • Kubernetes tends to be opinionated. It offers little customization (for now) and networking can be a challenge. But it is moving fast and the defaults can be a quick way to get started.
  • Docker Swarm is from Docker, Inc and offers the familiar Docker (single-host) API. It is the easiest to get started with, but also the least mature (as of this writing).

Container orchestration, scheduling and clustering tool vary in their features and implementation but some of the core principles are the same.

  • Pool resources from a group of hosts into their components (CPU/RAM) and make them available for consumption. Also make sure the resources don’t become exhausted via over-provisioning or host failure.
  • Service supervision provides a service load balancer/entry point and make sure the service remains running.
  • Scaling functionality scales a service (automatic or manually) by allowing an operator to create more or fewer instances.
  • System metadata provides stats about running instances, scheduling, and container health.

Going forward, I am going to do POC on above tools. I have already written couple of blog on Mesos and going to add more on reaming tools.

Setup Standalone Mesos on Ubuntu

Install DC/OS on Vagrant

Using Jenkins on DC/OS backed by NFS

Setup Standalone Mesos on Ubuntu


In this blog, I will walk you through setting up a standalone Apache Mesos and Marathon in ubuntu. Standalone installation means, running Mesos master, Mesos slave and Marathon on one machine. In this blog, we are going to install this mesos cluster on OpenStack VM. Even you can try on your local machine if you system running Ubuntu Operating System.

Introduction

Mesos is a scalable and distributed resource manager designed to manage resources for data centers.

Mesos can be thought of as “distributed kernel” that achieves resource sharing via APIs in various languages (C++, Python, Go, etc.) Mesos relies on cgroups to do process isolation on top of distributed file systems (e.g., HDFS). Using Mesos you can create and run clusters running heterogeneous tasks. Let us see what it is all about and some fundamentals on getting Mesos up and running.

Note: Even you can try DC/OS is an entirely open source software project based on Apache Mesos, Marathon and a whole lot more.

1. Add the Mesosphere Repositories to your Hosts

First, add the Mesosphere repository to your sources list. This process involves downloading the Mesosphere project’s key from the Ubuntu keyserver and then crafting the correct URL for our Ubuntu release. The project provides a convenient way of doing this:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
$ DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
$ CODENAME=$(lsb_release -cs)
$ echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/mesosphere.list

2. Download package lists and information of latest versions:

$ sudo apt-get -y update

3. Install Mesos and Marathon

A Mesos cluster needs at least one Mesos Master and one Mesos Slave. The Mesos Master coordinates and dispatch tasks onto the Mesos Slaves which run the jobs. In production clusters you typically run Mesos in High Availability (HA) Mode with three or more Mesos Masters, three or more Zookeepers, and many Mesos Slaves.

We will install Marathon and mesos meta package which also pulls in zookeeper as a dependency.

$ sudo apt-get -y install mesos marathon

4. Reboot the system:

$ sudo reboot

After the packages are downloaded and installed all of the Mesos and Marathon dependencies and startup scripts are ready for use on a single node cluster, including Apache ZooKeeper.

5. Mesos Web interface:

You should be able to access the Mesos web interface on port 5050 of your VM. For example, if the IP address of the VM is 192.168.0.131 then access the Mesos web UI at http://192.168.0.131:5050/. In case, if you have installed on your local system. Then you can access Mesos web UI on 127.0.0.1:5050. The master web console will show the number of active slaves as 1 and the registered Marathon framework. Take a few seconds to navigate around the interface to see what information is available.

scalable-jenkins

6. Marathon Web interface:

The Marathon web UI will be accessible at http://192.168.0.131:8080.

rsz_marathon

From here, you can click on the “Create” button in the upper-left corner. This will pop up an overlay where you can add information about your new application:

marathon_new_app

Fill in the fields with the requirements for your app. The only fields that are mandatory are:

  • ID: A unique ID selected by the user to identify a process. This can be whatever you’d like, but must be unique.
  • Command: This is the actual command that will be run by Marathon. This is the process that will be monitored and restarted if it fails.

Using this information, you can set up a simple service that just prints “hello” and sleeps for 10 seconds. We will call this “hello”:

simple_app

When you return to the interface, the service will go from “Deploying” to “Running”:

running

 

Install DC/OS on Vagrant


This installation method uses Vagrant to create a cluster of virtual machines on your local machine that can be used for demos, development, and testing with DC/OS.

Prerequisites

Your machine should have at least 16GB of RAM.

Note: If you are installing DC/OS on Vagrant, it only used for demos, development, and testing. Not use for production.

A) Download DC/OS Installer

First, it’s necessary to download the DC/OS 1.7.0 Installer. Save this somewhere safe – you’ll need this when setting up DC/OS Vagrant:

$ curl -O https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh

B) Install DC/OS Vagrant

1. Install & Configure Vagrant & VirtualBox

I assume, you have working Vagrant and VirtualBox on your machine. If not then first of all, Install Vagrant and Virtual box on your system.

Installing Virtualbox:

 $ sudo apt-get install virtualbox

Installing Vagrant:

$ sudo apt-get install vagrant

Install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the Linux kernel version changes during the next apt-get upgrade.

$ sudo apt-get install virtualbox-dkms

2. Clone DC/OS Vagrant Repo

Change the directory where you want to run the DC/OS and clone the dcos-vagrant repo and cd into it.

$ git clone https://github.com/dcos/dcos-vagrant
$ cd dcos-vagrant

You can also upgrade the latest version of dcos-vagrant:

  • Change into the repo directory (e.g. cd ~/workspace/dcos-vagrant)
  • Checkout the new desired version (e.g. git checkout v0.6.0)
  • Pull the new code (e.g. git pull)

3. Configure VirtualBox Networking

Configure the host-only vboxnet0 network to use the 192.168.65.0/24 subnet.

Create the vboxnet0 network if it does not exist:

$ VBoxManage list hostonlyifs | grep vboxnet0 -q || VBoxManage hostonlyif create

Set the vboxnet0 subnet:

$ VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.65.1

4. Install Vagrant Host Manager Plugin

The Host Manager Plugin manages the /etc/hosts on the VMs and host to allow access by hostname.

$ vagrant plugin install vagrant-hostmanager

This will update /etc/hosts every time VMs are created or destroyed.

5. Download the DC/OS Installer

As we already downloaded, we need to move dcos_generate_config.sh to the root of the repo (the repo will be mounted into the vagrant machines as /vagrant).

$ cd dcos_generate_config.sh dcos-vagrant

6. Configure the DC/OS Installer

As we have downloaded DC/OS 1.7.0 Installer so we will export etc/config-1.7.yaml to DCOS_CONFIG_PATH env variable.

$ export DCOS_CONFIG_PATH=etc/config-1.7.yaml

The path to the config file is relative to the repo dir, because the repo dir will be mounted as /vagrant within each VM. Alternate configurations may be added to the <repo>/etc/ dir and configured in a similar manner.

7. Configure the DC/OS Machine Types

There is sample VagrantConfig.yaml.example dcos-vagrant repo that we can configure for DC/OS machine type. At this point of time, we not need to do any changes.

cd <repo>
cp VagrantConfig.yaml.example VagrantConfig.yaml
8. Download the VM Base Image

By default, Vagrant will automatically download the latest VM Base Image (virtualbox box) when you run vagrant up <machines>, but since downloading the image takes a while the first time, you may want to trigger the download manually.

$ vagrant box add https://downloads.dcos.io/dcos-vagrant/metadata.json

If you already have the latest version downloaded, the above command will fail.

9. Deploy DC/OS

Specify which machines to deploy in your cluster. Below are a few options to try.

a) Minimal Cluster

A minimal cluster supports launching small Marathon apps. Most other services will fail to install, because they require more than one agent node.

Requires > 4.5GB free memory (using the example VagrantConfig).

$ vagrant up m1 a1 boot

b) Small Cluster

A small cluster supports running tasks on multiple nodes.

Requires > 7.25GB free memory (using the example VagrantConfig).

$ vagrant up m1 a1 a2 p1 boot

c) Medium Cluster

A medium cluster supports the installation of a minimally configured Cassandra.

Requires > 10GB free memory (using the example VagrantConfig).

$ vagrant up m1 a1 a2 a3 a4 p1 boot

d) Large Cluster

Requires > 17GB free memory (using the example VagrantConfig).

A large cluster supports master node fail over, multiple framework installs, and multiple public load balancers.

$ vagrant up m1 m2 m3 a1 a2 a3 a4 a5 a6 p1 p2 p3 boot
10. Access DC/OS from browser

Once the the machines are created and provisioned, DC/OS will be installed. Once complete, the Web Interface will be available at http://m1.dcos/.

11. Additionally you can Authentication DC/OS

If your DC/OS CLI or the web dashboard prompt for username and password then the superuser credentials are by default admin/admin