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

Mesos + Consul = Developer Happiness

Mesos + Consul = Developer Happiness

Talk given to the Denver Mesos Usergroup on July 9th, 2015

Brian Hicks

July 09, 2015
Tweet

More Decks by Brian Hicks

Other Decks in Programming

Transcript

  1. [{ "Address": "10.0.113.214", "Node": "batman-control-01", "ServiceAddress": "", "ServiceID": "marathon", "ServiceName":

    "marathon", "ServicePort": 18080, "ServiceTags": ["marathon"] }] curl localhost:8500/v1/catalog/service/marathon Query a Service over HTTP
  2. 10.0.113.214 10.0.220.54 10.0.131.25 1 1 18080 batman-control-02.node.batman.consul. 1 1 18080

    batman-control-03.node.batman.consul. 1 1 18080 batman-control-01.node.batman.consul. dig +short marathon.service.consul dig +short marathon.service.consul SRV SRV Records
  3. { "name": "marathon", "tags": [ "marathon", "dc-denver" ], "port": 18080,

    "check": { "script": "curl http://127.0.0.1:18080/ping", "interval": "10s" } } Service Definition
  4. { "name": "marathon", "tags": [ "marathon", "dc-denver" ], "port": 18080,

    "check": { "script": "curl http://127.0.0.1:18080/ping", "interval": "10s" } } Service Definition
  5. { "name": "marathon", "tags": [ "marathon", "dc-denver" ], "port": 18080,

    "check": { "script": "curl http://127.0.0.1:18080/ping", "interval": "10s" } } Service Definition
  6. { "name": "marathon", "tags": [ "marathon", "dc-denver" ], "port": 18080,

    "check": { "script": "curl http://127.0.0.1:18080/ping", "interval": "10s" } } Service Definition
  7. true [{ "CreateIndex": 223, "Flags": 0, "Key": "hello", "LockIndex": 0,

    "ModifyIndex": 223, "Value": "d29ybGQ=" }] curl -X PUT -d world http://localhost:8500/v1/kv/hello curl -X GET http://localhost:8500/v1/kv/hello Setting and Retrieving
  8. true false curl -X PUT -d denver http://localhost:8500/v1/kv/hello?cas=223 curl -X

    PUT -d world http://localhost:8500/v1/kv/hello?cas=1 Check and Set
  9. WAtches HTTP/1.1 200 OK Content-Type: application/json X-Consul-Index: 226 X-Consul-Knownleader: true

    X-Consul-Lastcontact: 0 Date: Mon, 29 Jun 2015 16:25:45 GMT Content-Length: 96 curl http://localhost:8500/v1/kv/hello?index=226
  10. consul-template This project provides a convenient way to populate values

    from Consul into the filesystem using the consul-template daemon. github.com/hashicorp/consul-template
  11. Haproxy Template global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults

    mode http timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}}
  12. Haproxy Template global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults

    mode http timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}}
  13. Haproxy Template global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults

    mode http timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}}
  14. Haproxy Template global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults

    mode http timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}}
  15. global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults mode http

    timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}} Haproxy Template
  16. global maxconn {{or (key "service/haproxy/maxconn") 256}} debug defaults mode http

    timeout connect {{or (key "service/haproxy/timeouts/connect") "5000ms"}} timeout client {{or (key "service/haproxy/timeouts/client") "50000ms"}} timeout server {{or (key "service/haproxy/timeouts/server") "50000ms"}} {{range services}} frontend {{.Name}} bind *:{{key (printf "ports/%s" .Name)}} {{range service .Name}} server {{.Node}} {{.Address}}:{{.Port}}{{end}} {{end}} Haproxy Template
  17. Colophon Eggs. Plenty of them. Alex Barth, Licensed CC BY

    2.0 https://www.flickr.com/photos/a-barth/4985481182 Dictionary Greeblie, Licensed CC BY 2.0 https://www.flickr.com/photos/greeblie/3338710223