Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Running Couchbase With Kubernetes: Part 1

DZone's Guide to

Running Couchbase With Kubernetes: Part 1

In this blog post we will explore how to get setup using Couchbase with Kubernetes and CoreOS. I will show you how to install a full bare metal Kubernetes solution by running all the components on your local machine.

· Database Zone
Free Resource

Traditional relational databases weren’t designed for today’s customers. Learn about the world’s first NoSQL Engagement Database purpose-built for the new era of customer experience.

In this blog post we will explore how to get setup 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.  

$mkdir couchbase-kubernetes
$cd couchbase-kubernetes/

 

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:

$ARCH=darwin; wget https://storage.googleapis.com/kubernetes-release/release/v1.0.6/bin/$ARCH/amd64/kubectl

You will see something similar as the below where the 'kubectl' is then saved.  I chose 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:

$file kubectl

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:

$chmod +x kubectl
$mv kubectl /usr/local/bin/kubectl

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:

$git clone https://github.com/coreos/coreos-kubernetes.git

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

$cd coreos-kubernetes/single-node/

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

$vagrant init hashicorp/precise64

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's run the virtual machine in VirtualBox by executing:

$vagrant up

What we see below is the process of getting the cluster ready with all the dependencies once Vagrant has finished booting and provisioning our machine.

Configuring kubectl

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

$kubectl config set-cluster vagrant --server=https://172.17.4.99:443 --certificate-authority=${PWD}/ssl/ca.pem

 

$kubectl config set-credentials vagrant-admin --certificate-authority=${PWD}/ssl/ca.pem --client-key=${PWD}/ssl/admin-key.pem --client-certificate=${PWD}/ssl/admin.pem

 

$kubectl config set-context vagrant --cluster=vagrant --user=vagrant-admin

 

$kubectl config use-context vagrant

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

$kubectl get nodes

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:

$git clone https://github.com/couchbase/kubernetes.git couchbase-kubernetes
$cd couchbase-kubernetes

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


Learn how the world’s first NoSQL Engagement Database delivers unparalleled performance at any scale for customer experience innovation that never ends.

Topics:
couchbase ,kubernetes ,coreos ,coreos-kubernetes-platform ,vagrant ,virtual box ,database

Published at DZone with permission of William Hoang, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}