diff --git a/conf/surok.json b/conf/surok.json index bed8ebc..c48ef84 100644 --- a/conf/surok.json +++ b/conf/surok.json @@ -1,22 +1,26 @@ { "marathon": { - "force": true, - "host": "http://marathon.mesos:8080", - "enabled": false - }, + "force": true, + "host": "http://marathon.mesos:8080", + "enabled": false + }, + "consul": { + "enabled": false, + "domain": "service.dc1.consul" + }, "confd": "/etc/surok/conf.d", "domain": "marathon.mesos", "wait_time": 20, "lock_dir": "/var/tmp", "loglevel": "info", - "container": false, - "memcached": { - "enabled": false, - "discovery": { - "enabled": false, - "service": "memcached", - "group": "system" - }, - "hosts": ["localhost:11211"] - } + "container": false, + "memcached": { + "enabled": false, + "discovery": { + "enabled": false, + "service": "memcached", + "group": "system" + }, + "hosts": ["localhost:11211"] + } } diff --git a/surok/discovery.py b/surok/discovery.py index 4f93da5..1e78730 100644 --- a/surok/discovery.py +++ b/surok/discovery.py @@ -14,7 +14,7 @@ def resolve(app, conf): for service in services: hosts[service['name']] = {} - + group = get_group(service, app) if group is False: error('Group is not defined in config, SUROK_DISCOVERY_GROUP and MARATHON_APP_ID') @@ -31,6 +31,13 @@ def resolve(app, conf): # This is fast fix for port naming # Will be rewrite later fqdn = '' + + # Discovery over Consul DNS + if 'consul' in conf and conf['consul']['enabled']: + fqdn = '_' + service['name'] + '._tcp.' + conf['consul']['domain'] + hosts[service['name']] = do_query(fqdn, conf['loglevel']) + continue + if ports is not None: for port_name in ports: fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain