Project

General

Profile

Consul » History » Version 3

Peter Amstutz, 10/26/2016 01:08 AM

1 1 Peter Amstutz
h1. Consul
2
3 3 Peter Amstutz
h2. Services
4 2 Peter Amstutz
5
Each service must have a unique id, but may have a common name, for example:
6
7
<pre>
8
{
9
  "service": {
10
    "id": "zzzzz-bi6l4-ydim6qekt9ut47f",
11
    "name": "keep",
12
    "port": 80
13
  }
14
}
15
</pre>
16
17
<pre>
18
{
19
  "service": {
20
    "id": "zzzzz-bi6l4-9e7boja2v94hfj5",
21
    "name": "keep",
22
    "port": 80
23
  }
24
}
25
</pre>
26
27
A query on the "keep" service returns multiple nodes:
28
29
<pre>
30
$ curl http://localhost:8500/v1/catalog/service/keep | jq .
31
[
32
  {
33
    "Node": "debian",
34
    "Address": "127.0.0.1",
35
    "TaggedAddresses": {
36
      "lan": "127.0.0.1",
37
      "wan": "127.0.0.1"
38
    },
39
    "ServiceID": "zzzzz-bi6l4-9e7boja2v94hfj5",
40
    "ServiceName": "keep",
41
    "ServiceTags": [],
42
    "ServiceAddress": "",
43
    "ServicePort": 443,
44
    "ServiceEnableTagOverride": false,
45
    "CreateIndex": 7,
46
    "ModifyIndex": 7
47
  },
48
  {
49
    "Node": "debian",
50
    "Address": "127.0.0.1",
51
    "TaggedAddresses": {
52
      "lan": "127.0.0.1",
53
      "wan": "127.0.0.1"
54
    },
55
    "ServiceID": "zzzzz-bi6l4-ydim6qekt9ut47f",
56
    "ServiceName": "keep",
57
    "ServiceTags": [],
58
    "ServiceAddress": "",
59
    "ServicePort": 80,
60
    "ServiceEnableTagOverride": false,
61
    "CreateIndex": 6,
62 1 Peter Amstutz
    "ModifyIndex": 6
63
  }
64
]
65
</pre>
66 3 Peter Amstutz
67
h2. Configuration management
68
69
Store configuration in Consul k/v store.  Union of configuration for API server, workbench, etc.
70
71
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.
72
73
h2. Deployment
74
75
# Service packages have dependency on consul and consul-template.
76
# Consul sets up to run automatically from systemd unit.
77
# Packages provide /etc/consul.d/package.json (e.g. /etc/consul.d/keepproxy.json) and consul-template for configuration file.
78
79
h2. Transition to Consul
80
81
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.