Configuring DC/OS access for Couchbase


How to use Couchbase Server and Couchbase Sync Gateway with DC/OS

This section is a quick guide on how to configure and use Couchbase Server and Couchbase Sync Gateway with DC/OS.


  • A running DC/OS 1.10 or 1.11 cluster


Couchbase can be installed using either the DC/OS Catalog web interface or the CLI.

Install via DC/OS web interface

When you launch Couchbase via the DC/OS Catalog web interface, choose Review & Run.

Couchbase Install

Figure 1. Couchbase install screen

Install via CLI

The following command will launch the install via the DC/OS CLI:

dcos package install couchbase

In either case, a default cluster will come up with two data nodes.

Couchbase Install Finished

Figure 2. Couchbase installed with two data nodes

You must change the configuration to also bring up index, query, full text search, eventing, and analytics nodes.

Accessing the Console

  1. Once the cluster is up and running, use the following command to get the mesos-id of the host running one of the data nodes.
$ dcos node
  1. Using the mesos-id, create a SSH localhost tunnel.
$ dcos node ssh --master-proxy --mesos-id=... --option LocalForward=8091=localhost:8091
  1. Open your browser and enter localhost:8091. When prompted for credentials, enter the defaults: Administrator / password.

Couchbase Creds

Figure 3. Couchbase credentials

This will open the Couchbase dashboard.

Couchbase Dashboard

Figure 4. Couchbase dashboard

Adding Nodes

Assume we have two data nodes, and we want to add one.

Couchbase Data Nodes

Figure 5. Couchbase with two data nodes

You must edit the configuration of your Couchbase service, and increase the data node count to 3.

Couchbase Edit configuration

Figure 6. Adding a Couchbase node

A third node is added and an automatic rebalance takes place.

Couchbase 3rd

Figure 7. Couchbase with three data nodes

Adding a Sync Gateway Node

We will use the PouchDB Getting Started app to demonstrate the use of the Couchbase Sync Gateway. You will not have to build the app yourself; we have it readily available in a Docker image. First we will create a data bucket, and then we will make the Couchbase Sync Gateway available.

Create a data bucket

  1. Create a bucket named todo, as shown below.

Data Bucket

Figure 8. Adding a data bucket

  1. Create a user named todo with password todo188, and give that user access to the todo bucket.

Add User

Figure 9. Granting access to user todo

  1. Use the following Couchbase Sync Gateway configuration.
    - Content-Type
    - '*'
    MaxAge: 1728000
    - '*'
        bucket: todo
        password: todo188
        username: todo
                - '*'
                disabled: false
- '*'
  1. Add a Couchbase Sync Gateway node to our couchbase service. Note that the former yml is already set as the default.

Edit Configuration

Figure 10. Editing the Couchbase Sync Gateway configuration

  1. Create a file named todo.json, with the following content. This is the PouchDB Getting Started app that accesses the Couchbase Sync Gateway.
  "id": "todo",
  "container": {
    "type": "MESOS",
    "docker": {
      "image": "mesosphere/pdbtd",
      "forcePullImage": true
  "portDefinitions": [
      "name": "api",
      "port": 8000,
      "protocol": "tcp",
      "labels": {
        "VIP_0": "todo:8000"
  "cmd": "python -m http.server $PORT0"
  1. Launch the todo app using the following command.
$ dcos marathon app add todo.json

Expose the Couchbase Sync Gateway node

Before we can use it, we must expose the Couchbase Sync Gateway service and the todo app using Edge-LB.

Install Edge-LB.

  1. Create a file named lb-sync-gateway.json containing the following Edge-LB configuration.
  "apiVersion": "V2",
  "name": "lb-sync-gateway",
  "count": 1,
  "haproxy": {
    "frontends": [
        "bindPort": 4984,
        "protocol": "HTTP",
        "linkBackend": {
          "defaultBackend": "sgw"
        "bindPort": 8000,
        "protocol": "HTTP",
        "linkBackend": {
          "defaultBackend": "todo"
    "backends": [
      "name": "sgw",
      "protocol": "HTTP",
      "services": [{
        "endpoint": {
          "type": "ADDRESS",
          "address": "",
          "port": 4984
      "name": "todo",
      "protocol": "HTTP",
      "services": [{
        "endpoint": {
          "type": "ADDRESS",
          "address": "",
          "port": 8000
  1. Launch the Edge-LB configuration using the following command.
$ dcos edgelb create lb-sync-gateway.json

Now everything is in place.

running Figure 11. Edge-LB and Couchbase running together

  1. Get the public IP of your DC/OS public agent, and enter the following in your browser: http://<public-ip>:8000 .


Figure 12. The todo list is up and running

As you enter items to your todo list, you will also be able to see them in the couchbase console in the todo bucket. If you open another browser, you will also see the DB synced there.