elodina/mesos-consul

Name: mesos-consul

Owner: Elodina

Description: Mesos to Consul bridge for service discovery

Created: 2015-11-03 13:15:29.0

Updated: 2017-04-04 17:39:54.0

Pushed: 2015-10-29 17:45:31.0

Homepage: null

Size: 180

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

mesos-consul

Mesos to Consul bridge for service discovery.

Mesos-consul automatically registers/deregisters services run as Mesos tasks.

This means if you have a Mesos task called application, this program will register the application in Consul, and it will be exposed via DNS as application.service.consul.

This program also does Mesos leader discovery, so that leader.mesos.service.consul will point to the current leader.

Table of Contents

Comparisons to other discovery software
Mesos-dns

This project is similar to mesos-dns in that it polls Mesos to get information about tasks. However, instead of exposing this information via a built-in DNS server, we populate Consul service discovery with this information. Consul then exposes the services via DNS and via its API.

Benefits of using Consul:

Registrator

Registrator is another tool that populates Consul (and other backends like etcd) with the status of Docker containers. However, Registrator is currently limited to reporting on Docker containers and does not track Mesos tasks.

Building
er build -t mesos-consul . 
Running

Mesos-consul can be run in a Docker container via Marathon. If your Zookeeper and Marathon services are registered in consul, you can use .service.consul to find them, otherwise change the vaules for your environment:

 -X POST -d@mesos-consul.json -H "Content-Type: application/json" http://marathon.service.consul:8080/v2/apps'

Where mesos-consul.json is similar to (replacing the image with your image):


rgs": [
"--zk=zk://zookeeper.service.consul:2181/mesos"
  
ontainer": {
"type": "DOCKER",
"docker": {
  "network": "BRIDGE",
  "image": "{{ mesos_consul_image }}:{{ mesos_consul_image_tag }}"
}   
  
d": "mesos-consul",
nstances": 1,
pus": 0.1,
em": 256 

You can add options to authenticate via basic http or Consul token.

Usage
Options

| Option | Description | |———————–|————-| | refresh | Time between refreshes of Mesos tasks | registry-auth | The basic authentication username (and optional password), separated by a colon. | registry-ssl | Use HTTPS while talking to the registry. | registry-ssl-verify | Verify certificates when connecting via SSL. | registry-ssl-cert | Path to an SSL certificate to use to authenticate to the registry server | registry-ssl-cacert | Path to a CA certificate file, containing one or more CA certificates to use to valid the reigstry server certificate | registry-token | The registry ACL token | zk* | Location of the Mesos path in Zookeeper. The default value is zk://127.0.0.1:2181/mesos

Consul Registration
Leader, Master and Follower Nodes

| Role | Registration |————|————– | Leader | leader.mesos.service.consul, master.mesos.service.consul | Master | master.mesos.service.consul | Follower | follower.mesos.service.consul

Mesos Tasks

Tasks are registered as task_name.service.consul

Tags

Tags can be added to consul by using labels in Mesos. If you are using Marathon you can add a label called tags to your service definition with a comma-separated list of strings that will be registered in consul as tags.

For example, in your marathon service definition:


d": "tagging-test",
ontainer": { /*...*/},
abels": {
"tags": "label1,label2,label3"


This will result in a service tagging-test being created in consul with 3 separate tags: label1 label2 and label3

ET /v1/catalog/service/tagging-test


Node: "consul",
Address: "10.0.2.15",
ServiceID: "mesos-consul:10.0.2.15:tagging-test:31562",
ServiceName: "tagging-test5",
ServiceTags: [
  "label1",
  "label2",
  "label3"
],
ServiceAddress: "10.0.2.15",
ServicePort: 31562


Todo

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.