Project

General

Profile

Consul » History » Revision 3

Revision 2 (Peter Amstutz, 10/26/2016 12:49 AM) → Revision 3/7 (Peter Amstutz, 10/26/2016 01:08 AM)

h1. Consul 

 h2. Services # Service packages have dependency on consul. 
 # Consul package runs automatically from systemd unit. 
 # Consul updates /etc/resolve.conf to use consul as DNS resolver (?) 
 # Packages provide /etc/consul.d/package.json (e.g. /etc/consul.d/keepproxy.json) 

 Each service must have a unique id, but may have a common name, for example: 

 <pre> 
 { 
   "service": { 
     "id": "zzzzz-bi6l4-ydim6qekt9ut47f", 
     "name": "keep", 
     "port": 80 
   } 
 } 
 </pre> 

 <pre> 
 { 
   "service": { 
     "id": "zzzzz-bi6l4-9e7boja2v94hfj5", 
     "name": "keep", 
     "port": 80 
   } 
 } 
 </pre> 

 A query on the "keep" service returns multiple nodes: 

 <pre> 
 $ curl http://localhost:8500/v1/catalog/service/keep | jq . 
 [ 
   { 
     "Node": "debian", 
     "Address": "127.0.0.1", 
     "TaggedAddresses": { 
       "lan": "127.0.0.1", 
       "wan": "127.0.0.1" 
     }, 
     "ServiceID": "zzzzz-bi6l4-9e7boja2v94hfj5", 
     "ServiceName": "keep", 
     "ServiceTags": [], 
     "ServiceAddress": "", 
     "ServicePort": 443, 
     "ServiceEnableTagOverride": false, 
     "CreateIndex": 7, 
     "ModifyIndex": 7 
   }, 
   { 
     "Node": "debian", 
     "Address": "127.0.0.1", 
     "TaggedAddresses": { 
       "lan": "127.0.0.1", 
       "wan": "127.0.0.1" 
     }, 
     "ServiceID": "zzzzz-bi6l4-ydim6qekt9ut47f", 
     "ServiceName": "keep", 
     "ServiceTags": [], 
     "ServiceAddress": "", 
     "ServicePort": 80, 
     "ServiceEnableTagOverride": false, 
     "CreateIndex": 6, 
     "ModifyIndex": 6 
   } 
 ] 
 </pre> 

 h2. Configuration management 

 Store configuration in Consul k/v store.    Union of configuration for API server, workbench, etc. 

 Use https://github.com/hashicorp/consul-template to write configuration files for individual components and automatically restart services when configuration files are updated by consul-template. 

 h2. Deployment 

 # Service packages have dependency on consul and consul-template. 
 # Consul sets up to run automatically from systemd unit. 
 # Packages provide /etc/consul.d/package.json (e.g. /etc/consul.d/keepproxy.json) and consul-template for configuration file. 

 h2. Transition to Consul 

 API endpoints currently used for service discovery such as the keep services table should be removed from the database and instead query Consul on the backend.