Couchbase Docker container can easily run on a variety of orchestration platforms:
- Couchbase Docker Container
- Couchbase on Docker Swarm
- Couchbase on Kubernetes
- Couchbase on OpenShift 3
Docker container using Apache Mesos and Marathon explained how to setup Mesos, Marathon, and run a simple Docker image. The setup was quite involving and a bit flaky.
It required to download and Install Mesos Master and Slave, ZooKeeper, Docker Engine, and Marathon. In some cases, the correct repo need to be added first. These components need to talk to each and so must be configured accordingly. Even if you get past that setup, how do you monitor the entire infrastructure as one entity?
Meet DC/OS – Datacenter Operating System. Its a distributed operating system using Apache Mesos as its kernel.
DC/OS can installed in a variety of ways:
- Local using Vagrant
- Cloud using Amazon/CloudFormation, Microsoft Azure and Packet
- On-prem using CentOS or CoreOS
This blog will show how to setup a DC/OS cluster using CloudFormation templates on Amazon and run a Couchbase Docker container.
Launch DC/OS cluster
Launch DC/OS cluster:
Give the template a name, select a previously create KeyPair, change the number of slaves:
Click on “I acknowledge that …” and on Create to start the template creation.
CloudFormation Stack Status page comes up:
Make sure to choose the appropriate region.
After ~10-15 mins, the status changes:
Wait for the status to change from CREATE_IN_PROGRESS
to CREATE_COMPLETE.
Download and Configure DC/OS CLI
DC/OS CLI can be used to manage your cluster nodes, install DC/OS packages, inspect the cluster state, and administer the DC/OS service subcommands.
Install DC/OS CLI on your local machine.
On your CloudFormation Stack Status page, select the created stack, Outputs
tab, and copy the address of Mesos master
.
Configure the DC/OS CLI to use this cluster:
1
2
3
4
|
./bin/dcos config set core.dcos_url https://couchbase-ElasticL-14LTDN783Y89T-1791879285.us-west-1.elb.amazonaws.com
[core.dcos_url]: changed from 'http://couchbase-ElasticL-UJ5K6BOZQX59-570103311.us-west-1.elb.amazonaws.com' to 'https://couchbase-ElasticL-14LTDN783Y89T-1791879285.us-west-1.elb.amazonaws.com'
|
Authenticate:
1
2
3
4
5
6
7
8
9
10
|
./bin/dcos auth login
Removed [core.dcos_acs_token]
Please go to the following link in your browser:
https://couchbase-ElasticL-14LTDN783Y89T-1791879285.us-west-1.elb.amazonaws.com/login?redirect_uri=urn:ietf:wg:oauth:2.0:oob
Enter authentication token:
|
Enter the URL in the browser, proceed to the unsafe URL:
Copy the token to your clipboard:
Paste the authentication token in the terminal window:
1
2
3
4
5
|
Enter authentication token: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik9UQkVOakZFTWtWQ09VRTRPRVpGTlRNMFJrWXlRa015Tnprd1JrSkVRemRCTWpBM1FqYzVOZyJ9.eyJlbWFpbCI6ImFydW4uZ3VwdGFAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImlzcyI6Imh0dHBzOi8vZGNvcy5hdXRoMC5jb20vIiwic3ViIjoiZ29vZ2xlLW9hdXRoMnwxMDExOTUyMTI0MDUxOTA0Njc1MTIiLCJhdWQiOiIzeUY1VE9TemRsSTQ1UTF4c3B4emVvR0JlOWZOeG05bSIsImV4cCI6MTQ2MzM1MjA1MSwiaWF0IjoxNDYyOTIwMDUxfQ.tFOy6GBPhnDbP0hI1ZU6jjlogHi4DX2bAGcdYsLywfCEMmv5OU9fUL88v2Kebjgd6gNAJoDF8QiO8zkQ3c4PGifXjiEoay8USjSWpnMbbezkH3AwIZM_-WNVVm0nfIBnCiY5wIgHkCpG_n4oBGdBbMgggtRPUrwPasNPtC_eYbQfwJeM3ByTUaTsarNe3FERbTpQbhKx2Lfc8Xp8AXuW8Up65SbOZr3Kp_jehiLgR-DL6llB4wZDopf8mjnq_5lpOYMtSaHPTlA33tdnhmHi6dPCPeRQEI1qBM6sWUWKs02kT1u42nOF9IYrKrfkzjb4LxwtZdsQt8Jb8CtJHkU0KA
[core.dcos_acs_token]: set
Login successful!
|
Mesos and Marathon UI
Mesos UI is available using the address of the Mesos master:
Click on Services
to see Marathon service already installed:
Click on marathon to see the list of tasks:
As expected for a freshly created cluster, no tasks have been assigned yet.
Click on Nodes
to see the nodes:
Install and Configure Marathon Load Balancer
DC/OS slave nodes are not directly exposed on the Internet. An “external” load balancer can be configured to expose the tasks running on the slaves.
Marathon-lb, short for Marathon Load Balancer, is a load balancer available as a Mesos service. It is based on HAProxy that provides proxying and load balancing for TCP and HTTP based applications, with features such as SSL support, HTTP compression, health checking and more. Marathon-lb subscribes to Marathon’s event bus and updates the HAProxy configuration in real time.
1
2
3
4
5
6
7
8
|
dcos package install marathon-lb
We recommend a minimum of 0.5 CPUs and 256 MB of RAM available for the Marathon-LB DCOS Service.
Continue installing? [yes/no] yes
Installing Marathon app for package [marathon-lb] version [1.2.1]
Marathon-lb DCOS Service has been successfully installed!
See https://github.com/mesosphere/marathon-lb for documentation.
|
Marathon service UI will show the LB task running:
AWS Load Balancer allows port 80 and 443 by default. We’ll run a Couchbase server that will be exposed at port 8091.
In CloudFormation Stack Status page, copy the value from Values
column of PublicSlaveDnsAddress
:
In AWS Console, select Load Balancers, add a new firewall rule to allow port 8091 on TCP:
Run Couchbase Server Docker container on DC/OS
Run Couchbase Server Docker container on DC/OS using the following configuration file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{
"id": "couchbase-mesos",
"container": {
"type": "DOCKER",
"docker": {
"image": "arungupta/couchbase",
"network": "BRIDGE",
"portMappings": [
{ "hostPort": 0, "containerPort": 8091, "servicePort": 8091 },
{ "hostPort": 0, "containerPort": 8092, "servicePort": 8092 },
{ "hostPort": 0, "containerPort": 8093, "servicePort": 8093 },
{ "hostPort": 0, "containerPort": 11210, "servicePort": 11210 }
],
"forcePullImage":true
}
},
"instances": 1,
"cpus": 2.0,
"mem": 2048,
"labels":{
"HAPROXY_GROUP":"external"
}
}
|
This configuration file uses arungupta/couchbase image that configures the Couchbase Server using pre-defined Couchbase REST API. This image is Couchbase Docker Image.
cpus
and mem
attributes define the processing memory needed to run this task.
Give the command to run Couchbase in DC/OS cluster:
1
2
3
|
~/tools/dcos/dcos/bin/dcos marathon app add couchbase-mesos.json
|
Use the previously copied for PublicSlaveDnsAddress
and access the Couchbase Web Console at http://<URI>:8091. In our case, the URL is: http://couchbase-publicsl-vjzmwpa38k6d-429093455.us-west-1.elb.amazonaws.com:8091/index.html.
This shows up the login page as:
Enter the login credentials as Administrator
and password
:
Learn more about Couchbase Web Console.
Marathon UI is updated to show all the running services:
Couchbase Docker image log can be seen in Log Viewer:
Mesos dashboard is updated to show the resources that are consumed:
Finally, the complete stack can be deleted from StackFormation template page:
Further reading:
- Latest DC/OS docs
- DC/OS Installation Guide
- Get Started with DC/OS
- Manage your DC/OS Cluster
- Service discovery and load balancing with DC/OS
- DC/OS Slack Channel
- Get Started with Couchbase
Enjoy!
Now, you’ve seen Couchbase on Docker Swarm, Couchbase on Kubernetes, Couchbase on OpenShift 3. This blog showed how to run a Couchbase Docker image on Mesos and DC/OS.
Where else would you like Couchbase container to run?
Source: http://blog.couchbase.com/2016/may/couchbase-mesos-dcos-amazon