Project

General

Profile

Consul » History » Version 5

Peter Amstutz, 10/26/2016 01:21 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 3 Peter Amstutz
74
h2. Deployment
75
76
# Service packages have dependency on consul and consul-template.
77 4 Peter Amstutz
# Consul and consul-template run automatically from systemd unit.
78
# 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.)
79
80 3 Peter Amstutz
81
h2. Transition to Consul
82
83
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.