Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HashiCorp Consul

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

HashiCorp Consul

Avatar for Heraud Kevin

Heraud Kevin

May 18, 2017
Tweet

More Decks by Heraud Kevin

Other Decks in Technology

Transcript

  1. Déployer, « scaler » et configurer une application avec Consul

    (et docker, consul-template, envconsul, HAProxy, python, …)
  2. Caractéristiques principales Service Discovery (DNS/HTTP) Multi Datacenter KV Storage Failure

    Detection + ACL + Web UI + Evènements distribués + « watch » + Métriques / Monitoring + …
  3. Enregistrement d’un service $ curl \ --request PUT \ --data

    @payload.json \ https://consul:8500/v1/agent/service/register { "service": { "id": "api-1", "name": "api", "tags": ["demo"], "address": "127.0.0.1", "port": 5000, "checks": { "name": "Health api", "http": "http://127.0.0.1:5000/api/health", "interval": "10s" } } }
  4. Architecture (HA) Gossip protocol : SWIM (Hashicorp Serf) Consensus Protocol

    : Raft • Si le client est hors ligne, une seule instance de l’application y sera également • L’application n’a besoin de connaitre qu’une seule adresse : 127.0.0.1:8600
  5. DNS lookup [tag.]<service>.service[.datacenter].<domain> $ dig SRV api.service.consul ; <<>> DiG

    9.10.4-P3 <<>> SRV api.service.consul ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52880 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; QUESTION SECTION: ;api.service.consul. IN SRV ;; ANSWER SECTION: api.service.consul. 0 IN SRV 1 1 5000 consul.node.dc1.consul. ;; ADDITIONAL SECTION: consul.node.dc1.consul. 0 IN A 10.0.2.15 ;; Query time: 1 msec ;; SERVER: 10.0.2.15#53(10.0.2.15) ;; WHEN: Thu May 11 13:16:55 UTC 2017 ;; MSG SIZE rcvd: 88
  6. Ajout d’un service --name api-node-1 -P app flask run --host=0.0.0.0

    --name api-node-2 -P app flask run --host=0.0.0.0
  7. Consul-template {{ range services }} backend {{ .Name }}_backend {{

    range service .Name }} server {{ .Node }}-{{ .Port }} {{ .Address }}:{{ .Port }}{{ end }} {{ end }} {{ range services }} acl host_{{ .Name }} hdr_beg(host) -i {{ .Name }}."haproxy.service.consul" use_backend {{ .Name }}_backend if host_{{ .Name }} {{ end }}
  8. KV Storage (HTTP API) $ curl -X PUT \ -d

    50000 \ http://consul:8500/v1/kv/global/config/hazelcast/client/connection_timeout true $ curl http://consul:8500/v1/kv/global/config/hazelcast/client/connection_timeout?raw 50000
  9. Script + Interval HTTP + Interval TCP + Interval Time

    to Live (TTL) Docker + Interval Failure Detection