Deploying Couchbase clusters the easy way with Triton and Docker

Couchbase, Docker, and Joyent's Elastic Container Service make deploying and scaling Couchbase clusters fast and easy. Triton's bare metal containers offer the elasticity and performance to meet the needs of the most demanding applications. These benefits are available for traditional deployments in infrastructure containers, but deployments in Docker containers enjoy an even greater level of built-in automation.

Couchbase's built-in cluster awareness and automatic management of data, including sharding and cross-datacenter replication make it ideal for deployment in Docker containers on Triton, while Triton's container-native infrastructure solves the network, performance, and security problems that have hampered many Dockerization efforts.

  • Convenient network access for every container. You'll never have to worry about port conflicts. Triton's built-in networking offer's each container one or more network interfaces, so the container has a full IP stack and is a full peer on the network. Need some containers private while exposing others to the public internet? Yep, Triton can do that.
  • Security baked in. Triton containers are built on Joyent's nearly ten years of experience running containers on multi-tenant bare metal. Joyent's security starts with a kernel built from the ground up specifically for running containers and extends all the way to patented resource protections that protect containers from noisy neighbors.
  • Bare metal performance. By eliminating layers of virtualization and running containers directly on bare metal, applications enjoy the highest possible performance. Hardware virtual machines can't match the filesystem and network I/O performance or workload density offered by Triton.
  • Docker, simplified: Docker-native tools make deploying in the cloud as easy as doing a docker run.... There's no special software to install or configure whether you're deploying one container or a hundred thousand.
  • Open source, our data center or yours. The same software that runs our data centers is available to run yours. Fork us on Github now.

Let's try this

If you don't already have a Joyent account, go get one now. With that and an SSH key loaded, get your environment setup with

  1. Install and configure the Joyent CloudAPI CLI tools.
  2. Install the Docker CLI and Docker Compose.
  3. Configure your Docker CLI and Compose for use with Joyent:
curl -O https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/sdc-docker-setup.sh && chmod +x sdc-docker-setup.sh ./sdc-docker-setup.sh -k us-east-3b.api.joyent.com  ~/.ssh/

Once your environment is all setup

  1. Clone or download the project repo.
  2. cd into the cloned or downloaded directory.
  3. Execute bash start.bash to start everything up.
  4. The Couchbase dashboard should automatically open. Sign in with the user/pass printed in the output of bash start.bash to see the working, one-node cluster.
  5. Scale the cluster using docker-compose --project-name=ccic scale up couchbase=$n and watch the node(s) join the cluster in the Couchbase dashboard.

Really, that's all it takes to launch a multi-node Couchbase cluster. Need more nodes? Just docker-compose --project-name=ccic scale up couchbase=100, or even higher. Try it out for yourself or watch the screencast to see how easy it is, then take a look at the detailed steps below to see how you can do it with your own apps.


Detailed instructions

Okay, let's take a look at how this works. The start.bash script automatically does the following:

docker-compose pulldocker-compose --timeout=120 --project-name=ccic up -d --no-recreate

Those Docker Compose commands read the docker-compose.yml, which describes the three services in the app. The second command, we can call it docker-compose up for short, provisions a single container for each of the services.

The three services include:

  • Couchbase, the database at the core of this application
  • Consul, to support service discovery and health checking among the different services
  • Couchbase Cloud Benchmarks, a benchmarking container to round out the picture

Consul is running in it's default configuration as delivered in Jeff Lindsay's excellent image, but Couchbase is wrapped with a custom start script that enables the magic here.

Once the first set of containers is running, the start.bash script bootstraps the Couchbase container with the following command:

docker exec -it ccic_couchbase_1 triton-bootstrap bootstrap benchmark

Look in the repo or at the bootstrap script itself for full details of what that command does, but the short story is that it initializes the cluster and creates a bucket, then registers this one node Couchbase service with the Consul container.

Because one Couchbase container can get lonely, it's best to scale it using the following command:

docker-compose --timeout=120 --project-name=ccic scale couchbase=$COUNT

Docker Compose will create new Couchbase containers according to the definition in the docker-compose.yml, and when those containers come online they'll check with Consul to see if there's an established cluster. When they find there is, they'll join that cluster and rebalance the data across the new nodes.



Post written by Casey Bisson