Consul » History » Version 2
Peter Amstutz, 10/26/2016 12:49 AM
| 1 | 1 | Peter Amstutz | h1. Consul |
|---|---|---|---|
| 2 | |||
| 3 | # Service packages have dependency on consul. |
||
| 4 | # Consul package runs automatically from systemd unit. |
||
| 5 | # Consul updates /etc/resolve.conf to use consul as DNS resolver (?) |
||
| 6 | # Packages provide /etc/consul.d/package.json (e.g. /etc/consul.d/keepproxy.json) |
||
| 7 | 2 | Peter Amstutz | |
| 8 | Each service must have a unique id, but may have a common name, for example: |
||
| 9 | |||
| 10 | <pre> |
||
| 11 | { |
||
| 12 | "service": { |
||
| 13 | "id": "zzzzz-bi6l4-ydim6qekt9ut47f", |
||
| 14 | "name": "keep", |
||
| 15 | "port": 80 |
||
| 16 | } |
||
| 17 | } |
||
| 18 | </pre> |
||
| 19 | |||
| 20 | <pre> |
||
| 21 | { |
||
| 22 | "service": { |
||
| 23 | "id": "zzzzz-bi6l4-9e7boja2v94hfj5", |
||
| 24 | "name": "keep", |
||
| 25 | "port": 80 |
||
| 26 | } |
||
| 27 | } |
||
| 28 | </pre> |
||
| 29 | |||
| 30 | A query on the "keep" service returns multiple nodes: |
||
| 31 | |||
| 32 | <pre> |
||
| 33 | $ curl http://localhost:8500/v1/catalog/service/keep | jq . |
||
| 34 | [ |
||
| 35 | { |
||
| 36 | "Node": "debian", |
||
| 37 | "Address": "127.0.0.1", |
||
| 38 | "TaggedAddresses": { |
||
| 39 | "lan": "127.0.0.1", |
||
| 40 | "wan": "127.0.0.1" |
||
| 41 | }, |
||
| 42 | "ServiceID": "zzzzz-bi6l4-9e7boja2v94hfj5", |
||
| 43 | "ServiceName": "keep", |
||
| 44 | "ServiceTags": [], |
||
| 45 | "ServiceAddress": "", |
||
| 46 | "ServicePort": 443, |
||
| 47 | "ServiceEnableTagOverride": false, |
||
| 48 | "CreateIndex": 7, |
||
| 49 | "ModifyIndex": 7 |
||
| 50 | }, |
||
| 51 | { |
||
| 52 | "Node": "debian", |
||
| 53 | "Address": "127.0.0.1", |
||
| 54 | "TaggedAddresses": { |
||
| 55 | "lan": "127.0.0.1", |
||
| 56 | "wan": "127.0.0.1" |
||
| 57 | }, |
||
| 58 | "ServiceID": "zzzzz-bi6l4-ydim6qekt9ut47f", |
||
| 59 | "ServiceName": "keep", |
||
| 60 | "ServiceTags": [], |
||
| 61 | "ServiceAddress": "", |
||
| 62 | "ServicePort": 80, |
||
| 63 | "ServiceEnableTagOverride": false, |
||
| 64 | "CreateIndex": 6, |
||
| 65 | "ModifyIndex": 6 |
||
| 66 | } |
||
| 67 | ] |
||
| 68 | </pre> |