Consul DNS discovery. Related to #12

This commit is contained in:
Denis Zheleztsov 2017-01-21 10:58:02 +03:00
parent fc4e2b1b47
commit 3511f13180
2 changed files with 26 additions and 15 deletions

View File

@ -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"]
}
}

View File

@ -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