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": { "marathon": {
"force": true, "force": true,
"host": "http://marathon.mesos:8080", "host": "http://marathon.mesos:8080",
"enabled": false "enabled": false
}, },
"consul": {
"enabled": false,
"domain": "service.dc1.consul"
},
"confd": "/etc/surok/conf.d", "confd": "/etc/surok/conf.d",
"domain": "marathon.mesos", "domain": "marathon.mesos",
"wait_time": 20, "wait_time": 20,
"lock_dir": "/var/tmp", "lock_dir": "/var/tmp",
"loglevel": "info", "loglevel": "info",
"container": false, "container": false,
"memcached": { "memcached": {
"enabled": false, "enabled": false,
"discovery": { "discovery": {
"enabled": false, "enabled": false,
"service": "memcached", "service": "memcached",
"group": "system" "group": "system"
}, },
"hosts": ["localhost:11211"] "hosts": ["localhost:11211"]
} }
} }

View File

@ -31,6 +31,13 @@ def resolve(app, conf):
# This is fast fix for port naming # This is fast fix for port naming
# Will be rewrite later # Will be rewrite later
fqdn = '' 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: if ports is not None:
for port_name in ports: for port_name in ports:
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain