Consul
Consul
Discover and configure services
Host Clustering and Failure Detection
Key/Value Configuration Storage
Monitoring Services
Service Discovery
• Provide Services
• Discover Services
• HTTP and DNS
• Support for SaaS services
Health Monitoring
• Failure detection
• Collect metrics
• Prevent routing to unhealthy hosts
Key/Value Storage
• Simple usage
• Dynamic configuration
Configuration
$ sudo mkdir /etc/consul.d
$ echo ‘{“check”: {“name”: “ping”, “interval”: “30s”, 
“script”: “ping –c1 google.com > /dev/null” }}’ 
> /etc/consul.d/ping.json
$ echo ‘{“service”: {“name”: “web”, “tags”: [“nancy”], “port”: 80, 
“check”: {“interval”: “10s”, “script”: 
“curl localhost > /dev/null 2 > &1”}}}’ 
> /etc/consul.d/web.json
consul agent -server
$ consul agent –server –data-dir /tmp/consul –config-dir /etc/consul.d
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
Node name: ‘khellang’
Datacenter: ‘miles01’
Server: true
Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400)
Cluster Add: 10.1.10.38 (LAN: 8301, WAN: 8302)
...
[INFO] agent: Synced service ‘web’
[INFO] agent: Synced check ‘service:web’
[INFO] agent: Synced check ‘ping’
[WARN] Check ‘service:web’ is now critical
...
consul members
$ consul members
Node Address Status Type Build Protocol
khellang 10.1.10.38:8301 alive server 0.5.1 2
$ curl localhost:8500/v1/catalog/nodes
[{“Node”:”khellang”,”Address”:”10.1.10.38”}]
Discover services
$ curl http://localhost:8500/v1/catalog/services/web
[{“Node”:”khellang”,”Address”:”10.1.10.38”,”ServiceID”:”web”, 
“ServiceName”:”web”,”ServiceTags”:[“rails”],”ServicePort”:80}]
consul join
$ consul join 10.1.10.38
Successfully joined clusted by contacting 1 nodes.
$ consul members
Node Address Status Type Build Protocol
khellang 10.1.10.38:8301 alive server 0.5.1 2
njmittet 10.1.10.39:8301 alive client 0.5.0 2
Checking Health
$ curl http://localhost:8500/v1/health/state/critical
[{“Node”:”khellang”,”CheckID”:”service:web”,
”Name”:”Service ‘web’ check”,”Status”:”critical”,”Notes”:””,
”ServiceID”:”web”,”ServiceName”:”web”}]
Web UI
Demo

Intro to Consul

  • 1.
  • 2.
  • 3.
    Host Clustering andFailure Detection Key/Value Configuration Storage Monitoring Services
  • 4.
    Service Discovery • ProvideServices • Discover Services • HTTP and DNS • Support for SaaS services
  • 5.
    Health Monitoring • Failuredetection • Collect metrics • Prevent routing to unhealthy hosts
  • 6.
    Key/Value Storage • Simpleusage • Dynamic configuration
  • 7.
    Configuration $ sudo mkdir/etc/consul.d $ echo ‘{“check”: {“name”: “ping”, “interval”: “30s”, “script”: “ping –c1 google.com > /dev/null” }}’ > /etc/consul.d/ping.json $ echo ‘{“service”: {“name”: “web”, “tags”: [“nancy”], “port”: 80, “check”: {“interval”: “10s”, “script”: “curl localhost > /dev/null 2 > &1”}}}’ > /etc/consul.d/web.json
  • 8.
    consul agent -server $consul agent –server –data-dir /tmp/consul –config-dir /etc/consul.d ==> Starting Consul agent... ==> Starting Consul agent RPC... ==> Consul agent running! Node name: ‘khellang’ Datacenter: ‘miles01’ Server: true Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400) Cluster Add: 10.1.10.38 (LAN: 8301, WAN: 8302) ... [INFO] agent: Synced service ‘web’ [INFO] agent: Synced check ‘service:web’ [INFO] agent: Synced check ‘ping’ [WARN] Check ‘service:web’ is now critical ...
  • 9.
    consul members $ consulmembers Node Address Status Type Build Protocol khellang 10.1.10.38:8301 alive server 0.5.1 2 $ curl localhost:8500/v1/catalog/nodes [{“Node”:”khellang”,”Address”:”10.1.10.38”}]
  • 10.
    Discover services $ curlhttp://localhost:8500/v1/catalog/services/web [{“Node”:”khellang”,”Address”:”10.1.10.38”,”ServiceID”:”web”, “ServiceName”:”web”,”ServiceTags”:[“rails”],”ServicePort”:80}]
  • 11.
    consul join $ consuljoin 10.1.10.38 Successfully joined clusted by contacting 1 nodes. $ consul members Node Address Status Type Build Protocol khellang 10.1.10.38:8301 alive server 0.5.1 2 njmittet 10.1.10.39:8301 alive client 0.5.0 2
  • 12.
    Checking Health $ curlhttp://localhost:8500/v1/health/state/critical [{“Node”:”khellang”,”CheckID”:”service:web”, ”Name”:”Service ‘web’ check”,”Status”:”critical”,”Notes”:””, ”ServiceID”:”web”,”ServiceName”:”web”}]
  • 13.

Editor's Notes

  • #3 Laget av HashiCorp, f