Couchbase on Kubernetes

This blog is possible because of this tweet!

Kubernetes is an open source orchestration system by Google for Docker containers.  It manages containerized applications across multiple hosts and provides basic mechanisms for deployment, maintenance, and scaling of applications.

It allows the user to provide declarative primitives for the desired state, for example “need 5 Couchbase servers”. Kubernetes self-healing mechanisms, such as auto-restarting, re-scheduling, and replicating containers then ensure that this state is met. The user just define the state and Kubernetes ensures that the state is met at all times on the cluster.

Key Concepts of Kubernetes explains the key concepts of Kubernetes.

This multi-part blog series will show how to run Couchbase on Kubernetes in multiple ways. The first part starts with a simple setup using Vagrant.

Getting Started with Kubernetes

There are multiple ways to run Kubernetes but I found the simples (not necessarily predictable �� way is to run using Vagrant.

  • Download the latest Kubernetes release, 1.1.8 as of this writing, and expand the archive.
  • Start the Kubernetes cluster as:
    cd kubernetes
    export KUBERNETES_PROVIDER=vagrant

    This shows the output as:

    kubernetes-1.1.8 > ./kubernetes/cluster/ 
    ... Starting cluster using provider: vagrant
    ... calling verify-prereqs
    ... calling kube-up
    Bringing machine 'master' up with 'virtualbox' provider...
    Bringing machine 'minion-1' up with 'virtualbox' provider...
    ==> master: Importing base box 'kube-fedora21'...
    . . .
    Validate output:
    NAME                 STATUS    MESSAGE              ERROR
    controller-manager   Healthy   ok                   nil
    scheduler            Healthy   ok                   nil
    etcd-0               Healthy   {"health": "true"}   nil
    etcd-1               Healthy   {"health": "true"}   nil
    Cluster validation succeeded
    Done, listing cluster services:
    Kubernetes master is running at
    Heapster is running at
    KubeDNS is running at
    KubeUI is running at
    Grafana is running at
    InfluxDB is running at

Run Couchbase on Kubernetes Cluster

The easiest way to start running a Docker container in Kubernetes is using the kubectl run command.

The command usage is:

kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [flags]

The command runs a particular image, possibly replicated. The image replication is handled by creating a Replication Controller to manage the created container(s).

Complete list of options to run this command can be seen using:

./cluster/ run --help

Couchbase Docker Container explains the different Docker container for Couchbase. For this blog, we’ll use arungupta/couchbase image as that is pre-configured.

./cluster/ run couchbase --image=arungupta/couchbase

This shows the output:

replicationcontroller "couchbase" created

The output confirms that a Replication Controller is created. Lets verify it:

./kubernetes/cluster/ get rc
couchbase    couchbase      arungupta/couchbase   run=couchbase   1          17s

Now, check the pods:

./kubernetes/cluster/ get po
NAME              READY     STATUS    RESTARTS   AGE
couchbase-tzdhl   0/1       Pending   0          36s

Lets check the status of the pod:

./kubernetes/cluster/ describe pod couchbase-tzdhl
Name:                couchbase-tzdhl
Namespace:            default
Image(s):            arungupta/couchbase
Start Time:            Fri, 26 Feb 2016 18:05:10 -0800
Labels:                run=couchbase
Status:                Running
Replication Controllers:    couchbase (1/1 replicas created)
    Container ID:    docker://56dddb66bf60a590e588b972d5cae997ec96149066a9fb8075548c982eb14961
    Image:        arungupta/couchbase
    Image ID:        docker://080e2e96b3fc22964f3dec079713cdf314e15942d6eb135395134d629e965062
    QoS Tier:
      cpu:    Burstable
      cpu:        100m
    State:        Running
      Started:        Fri, 26 Feb 2016 18:05:56 -0800
    Ready:        True
    Restart Count:    0
    Environment Variables:
  Type        Status
  Ready     True 
    Type:    Secret (a secret that should populate this volume)
    SecretName:    default-token-clfeb
  FirstSeen    LastSeen    Count    From            SubobjectPath                Reason        Message
  ─────────    ────────    ─────    ────            ─────────────                ──────        ───────
  1m        1m        1    {scheduler }                            Scheduled    Successfully assigned couchbase-tzdhl to
  1m        1m        1    {kubelet}    implicitly required container POD    Pulling        Pulling image ""
  59s        59s        1    {kubelet}    implicitly required container POD    Created        Created with docker id 2dac5f81f4c2
  59s        59s        1    {kubelet}    spec.containers{couchbase}        Pulling        Pulling image "arungupta/couchbase"
  59s        59s        1    {kubelet}    implicitly required container POD    Started        Started with docker id 2dac5f81f4c2
  59s        59s        1    {kubelet}    implicitly required container POD    Pulled        Successfully pulled image ""
  19s        19s        1    {kubelet}    spec.containers{couchbase}        Pulled        Successfully pulled image "arungupta/couchbase"
  18s        18s        1    {kubelet}    spec.containers{couchbase}        Created        Created with docker id 56dddb66bf60
  18s        18s        1    {kubelet}    spec.containers{couchbase}        Started        Started with docker id 56dddb66bf60

Fifth line of the output says the node’s IP is This would be used to access the Web Console later.

The last line in this output shows that the pod is now ready. Checking the status of the pod again shows:

./kubernetes/cluster/ get po
NAME              READY     STATUS    RESTARTS   AGE
couchbase-tzdhl   1/1       Running   0          2m

Couchbase Web Console on Kubernetes Cluster

Now that your Couchbase container is running in Kubernetes cluster, you may like to view the Web Console.

Each pod is assigned a unique IP address, but this address is only accessible within the cluster. It can exposed using the kubectl expose command.

This command takes a Replication Controller, Service or Pod and expose it as new Kubernetes Service. This can be done by giving the command:

./cluster/ expose rc couchbase --target-port=8091 --port=8091 --external-ip=
service "couchbase" exposed

In this command:

  • --target-port is the name or number for the port on the container that the service should direct traffic to
  • --port is the port that the service should serve on
  • --external-ip is the external IP address to set for the service. Note, this IP address was obtained with kubectl describe pod command earlier.

Now, you can access the Couchbase Web Console at and looks like:


Enter the password credentials as Administrator/password. These credentials are specified during Docker image creation at



Discuss with us at StackOverflow or Couchbase Forums. You can also follow us at @couchbasedev and @couchbase.

Reference: Couchbase on Kubernetes from our JCG partner Arun Gupta at the Miles to go 2.0 … blog.

Arun Gupta

Arun is a technology enthusiast, avid runner, author of a best-selling book, globe trotter, a community guy, Java Champion, JavaOne Rockstar, JUG Leader, Minecraft Modder, Devoxx4Kids-er, and a Red Hatter.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button