Project

General

Profile

Actions

Consul » History » Revision 5

« Previous | Revision 5/7 (diff) | Next »
Peter Amstutz, 10/26/2016 01:21 AM


Consul

Services

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

{
  "service": {
    "id": "zzzzz-bi6l4-ydim6qekt9ut47f",
    "name": "keep",
    "port": 80
  }
}
{
  "service": {
    "id": "zzzzz-bi6l4-9e7boja2v94hfj5",
    "name": "keep",
    "port": 80
  }
}

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

$ 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
  }
]

Configuration management

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

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.

Deployment

  1. Service packages have dependency on consul and consul-template.
  2. Consul and consul-template run automatically from systemd unit.
  3. 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.)

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.

Updated by Peter Amstutz over 7 years ago · 5 revisions