In this blog we will explore how to get setup with using Couchbase with Kubernetes and CoreOS.  There are various deployment strategies ranging from the bare metal physical servers to virtual machines in the cloud or by using a fully managed solution from major cloud providers.  For this series, we will be installing a full bare metal Kubernetes solution by running all the components on your local machine.  There are a couple of prerequisites and we will go into each a bit to understand the overall picture.  The environment I am using for this blog is:

First we need to setup Kubernetes and we will use Vagrant and CoreOS.  Vagrant allows you to create consistent development environments quickly across various members of your team.  You may read more on the benefits of using Vagrant.  Go to the downloads page and select the package of your choice.  At the time of writing, we are targeting Vagrant 1.7.4 for MAC OSX against Virtual Box 5.0.8

Open the vagrant .dmg package and follow through on the installation instructions.  Next we will initiate Vagrant.

Download Kubernetes

From within your terminal application, create a new folder and navigate to that folder.  For the example, I created a folder named 'couchbase-kubernetes' and that is where we will spend the majority of our time.  'kubectl' is the main command CLI tool that we will use for interacting with the Kubernetes API.  

 

From within the 'couchbase-kubernetes' folder, we will download the binaries.  First install the package manager, Homebrew, if you have not already and execute a 'wget' on:

You will see something similar as the below where the 'kubectl' is then saved.  I choose the 'darwin' environment as I am on MacOSX and you can also choose 'linux' depending on your workstation operating system. 

Check to see if the binary is an executable by executing:

You should see that the 'kubectl' file exists and that it is an executable x86_64 like below.

Let us move 'kubectl' into our PATH by executing:

Run Kubernetes on top of CoreOS

Now we are ready to setup the virtual machines that will be running Kubernetes on CoreOS.  First we will clone the repository that contains a Vagrantfile.  The 'Vagrantfile' will have the configurations of the Kubernetes virtual machines.  Execute the command:

You should now have the 'coreos-kubernetes' repo after seeing something similar below

Start Kubernetes

Now we are ready to start our machine.  To do that let us first navigate to the 'single-node' folder where we will initiate Vagrant

From within the 'single-node' folder we will now execute the commands below to have a fully running virtual machine in VirtualBox.

Targeting the 64-bit version, below is what will see during the process of setting up the Ubuntu 12.04 LTS 64-bit box.

Next up let us run the virtual machine in VirtualBox by executing:

Configuring kubectl

From within the 'single-node' directory, we will next configure the local Kubernetes client with the commands below.

 

 

 

 

Now that everything is ready, you can see your cluster's status and its configuration information by executing:

Congrats!  Now you have a Kubernetes cluster running and set up.  This is the first step before running Couchbase on it.  Next we will explore how to run Couchbase in the Kubernetes cluster.

Setting Up Couchbase

From within the 'single-node' directory, we will start bringing in the Couchbase pieces.  From there we can then configure Couchbase to specific service logics.  We begin by cloning the Couchbase-Kubernetes repo:

 

In our next blog on Couchbase and Kubernetes, we will go through in concept and in configuring and running the Service and Replication Controllers for Couchbase!  

 

Posted by William Hoang, Mobile Developer Advocate, Couchbase

William was a Developer Advocate on the Mobile Engineering/Developer Experience team at Couchbase. His love for coffee and code has transcended him into the world of mobile while appreciating the offline in-person experiences. Prior, William worked on the Developer Relations team over at Twitter, BlackBerry, and Microsoft while also having been a Software Embedded GPS engineer at Research In Motion. William graduated from McGill University in Electrical Software Engineering

Leave a reply