Home Explore Blog CI



kubernetes

1st chunk of `content/en/blog/_posts/2016-08-00-Create-Couchbase-Cluster-Using-Kubernetes.md`
236c3a33b33e0edb3705d129dd6788d30e01e372aa07c78a0000000100000e69
---
title: " Create a Couchbase cluster using Kubernetes "
date: 2016-08-15
slug: create-couchbase-cluster-using-kubernetes
url: /blog/2016/08/Create-Couchbase-Cluster-Using-Kubernetes
author: >
  Arun Gupta (Couchbase)
---

[Couchbase Server](http://www.couchbase.com/nosql-databases/couchbase-server) is an open source, distributed NoSQL document-oriented database. It exposes a fast key-value store with managed cache for submillisecond data operations, purpose-built indexers for fast queries and a query engine for executing SQL queries. For mobile and Internet of Things (IoT) environments, [Couchbase Lite](http://developer.couchbase.com/mobile) runs native on-device and manages sync to Couchbase Server.  

Couchbase Server 4.5 was [recently announced](http://blog.couchbase.com/2016/june/announcing-couchbase-server-4.5), bringing [many new features](http://developer.couchbase.com/documentation/server/4.5/introduction/whats-new.html), including [production certified support for Docker](http://www.couchbase.com/press-releases/couchbase-announces-support-for-docker-containers). Couchbase is supported on a wide variety of orchestration frameworks for Docker containers, such as Kubernetes, Docker Swarm and Mesos, for full details visit [this page](http://couchbase.com/containers).    

This blog post will explain how to create a Couchbase cluster using Kubernetes. This setup is tested using Kubernetes 1.3.3, Amazon Web Services, and Couchbase 4.5 Enterprise Edition.  

Like all good things, this post is standing on the shoulder of giants. The design pattern used in this blog was defined in a [Friday afternoon hack](https://twitter.com/arungupta/status/703378246432231424) with [@saturnism](https://twitter.com/saturnism). A working version of the configuration files was [contributed](https://twitter.com/arungupta/status/759059647680552962) by [@r\_schmiddy](http://twitter.com/r_schmiddy).  



**Couchbase Cluster**



A cluster of Couchbase Servers is typically deployed on commodity servers. Couchbase Server has a peer-to-peer topology where all the nodes are equal and communicate to each other on demand. There is no concept of master nodes, slave nodes, config nodes, name nodes, head nodes, etc, and all the software loaded on each node is identical. It allows the nodes to be added or removed without considering their “type”. This model works particularly well with cloud infrastructure in general. For Kubernetes, this means that we can use the exact same container image for all Couchbase nodes.



A typical Couchbase cluster creation process looks like:

- Start Couchbase: Start n Couchbase servers
- Create cluster: Pick any server, and add all other servers to it to create the cluster
- Rebalance cluster: Rebalance the cluster so that data is distributed across the cluster



In order to automate using Kubernetes, the cluster creation is split into a “master” and “worker” Replication Controller (RC).



The master RC has only one replica and is also published as a Service. This provides a single reference point to start the cluster creation. By default services are visible only from inside the cluster. This service is also exposed as a load balancer. This allows the [Couchbase Web Console](http://developer.couchbase.com/documentation/server/current/admin/ui-intro.html) to be accessible from outside the cluster.



The worker RC use the exact same image as master RC. This keeps the cluster homogenous which allows to scale the cluster easily.



 ![](https://lh6.googleusercontent.com/yS4MqPJG6hQeFa8jcLL9CKy0dD6waghxzFAccS5OIDQJwGNsRmBN531RsByypTBILdJ0yFT3HmbaXOCKgiUr836zx50uOnxa5SIeWb1VaOqo_adepGnJe4L-LATAQtlrQgte7Je1)

Title: Creating a Couchbase Cluster Using Kubernetes
Summary
This blog post explains how to create a Couchbase cluster using Kubernetes, tested with Kubernetes 1.3.3, Amazon Web Services, and Couchbase 4.5 Enterprise Edition. It details the peer-to-peer topology of Couchbase Server, where all nodes are equal and communicate on demand, and how this works well with cloud infrastructure and Kubernetes. The cluster creation process involves starting Couchbase servers, creating the cluster by adding servers to one another, and rebalancing the cluster to distribute data. The setup uses a "master" and "worker" Replication Controller (RC) to automate cluster creation, with the master RC providing a single reference point and exposed as a load balancer for external access to the Couchbase Web Console.