Project

General

Profile

Consul » History » Version 7

Peter Amstutz, 10/26/2016 01:23 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 5 Peter Amstutz
Store configuration in Consul k/v store.  Union of configuration for API server, workbench, etc.  Can store master configuration file as a json file in git and push into k/v store using a tool such as https://github.com/gmr/consulate
70 1 Peter Amstutz
71 5 Peter Amstutz
Use https://github.com/hashicorp/consul-template to write configuration files for individual components based on central configuration.  Automatically restart services when configuration files are updated by consul-template.
72
73 7 Peter Amstutz
Services could eventually migrate to query Consul directly instead of using consul-template.
74
75 3 Peter Amstutz
76
h2. Deployment
77
78
# Service packages have dependency on consul and consul-template.
79 4 Peter Amstutz
# Consul and consul-template run automatically from systemd unit.
80
# Orchestration system (terraform? puppet?) installs/updates packages, installs /etc/consul.d/service.json (e.g. /etc/consul.d/keepproxy.json), consul-template for configuration file.  (Unclear if service.json and consul-template should be part of package or installed some other way.)
81
82 3 Peter Amstutz
h2. Transition to Consul
83 1 Peter Amstutz
84 6 Peter Amstutz
API endpoints currently used for service discovery such as the keep services table should be removed from postgres and instead query Consul on the backend.