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

@ -4,6 +4,10 @@
"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,

View File

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