Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Service routing with Consul & HAProxy
Search
cldmnky
September 08, 2016
Technology
270
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Service routing with Consul & HAProxy
From Stockholm HashiCorp User Group meetup #1, Sept 8, 2016.
cldmnky
September 08, 2016
More Decks by cldmnky
See All by cldmnky
Customizing and scaling Kubernetes for News
cldmnky
1
35
Choosing your scheduler wisely
cldmnky
1
130
Other Decks in Technology
See All in Technology
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
340
継続的なAIコスト最適化
bgpat
1
340
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
300
Kiro Crewをはじめよう
kizawa2020
1
160
re:Invent初参加で変わったこと、2回目にやってみたいこと(JAWS-UG彩の国埼玉 #12)
mhrtech
2
230
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
140
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
590
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
180
Local CI × GitHub Actions
gogutan
2
210
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
hackers_champloo_2026_tidb
makocchi
0
160
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Statistics for Hackers
jakevdp
799
230k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Product Roadmaps are Hard
iamctodd
55
13k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
エンジニアに許された特別な時間の終わり
watany
109
250k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
630
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
BBQ
matthewcrist
90
10k
Transcript
Service routing with Consul & HAProxy
[email protected]
stats ~ 300 deploys / week ~ 800 new
containers / week ~ 2k req’s / sec on haproxy
problem accessing our services?
problem Availability?
need Standardized access layer
summary tools used how we access services
takeaways
tools? not batteries included but removable, but rather just
the bag of batteries for us to play with!
tao Simple, Modular, Composable ’the tao of HashiCorp’
tools Consul
Consul… service catalog [tags].name
Consul… DNS interface: tag.name.service.consul
Consul… HTTP api: $ curl localhost:8500/v1/catalog/services {
"consul": [], "redis": [], "postgresql": [ "master", "slave" ] }
Consul… distributed K/V
Consul… health checks
tools Helios
tools Helios -‐> Nomad
tools registrator https://github.com/gliderlabs/registrator
Registrator… registers(!)
Registrator… docker.sock
tools consul-‐template
consul-‐template… populate data in files
consul-‐template… Go templating
consul-‐template… re-‐render on changes
consul-‐template… ..in service catalog
consul-‐template… ..in k/v
consul-‐template… ..and do action
tools HAProxy
HAProxy… L4-‐L7 TCP Proxy
HAProxy… small, fast, simple but powerful
about service discovery… a few ways to do it
service discovery with consul Service A api:20012
service discovery with consul 1.api? Service A api:20012
service discovery with consul 1.api? 2. api=10.50.0.10:20012 Service A
api:20012
service discovery with consul 1.api? 2. api=10.50.0.10:20012 Service A
api:20012 3.api!
service routing with HAProxy Service api api
service routing with HAProxy Service api for each service…
api
service routing with HAProxy api: 10.50.0.10:20012 Service api for
each service… api
service routing with HAProxy api: 10.50.0.10:20012 Service production.api api
for each service… api
service routing with HAProxy api: 10.50.0.10:20012 Service production.api api
for each service… api
www.expressen.se Bigip HAProxy Scheduler Agent Docker Consul- template registrator HAProxy
Scheduler Agent Docker Consul- template registrator
templating Let’s create a dashboard!
templating … <h1>Dashboard for: {{datacenters | join " "}}</h1> {{range
services}} {{range service .Name "any"}} <p> Name: {{.Name}} Tags: {{range .Tags}}{{.}}{{end}} Status: {{if ne .Status "passing"}}<span style="background- color:red">{{.Status}} state!</span>{{end}} {{if eq .Status "passing"}}<span style="background- color:green;">Ok</span>{{end}} </p> {{end}} {{end}} …
HAProxy basics frontends
HAProxy basics backends
HAProxy routing name-‐based Host:production.api.service.consul
HAProxy routing port frontend api-in bind 0.0.0.0:1234
feeding HAProxy frontends (in) frontend http-in bind 0.0.0.0:80 mode
http {{range $key, $pairs := tree "env/prod/haproxy/sites/" | explode }} {{ if $pairs }}{{ if $pairs.backends }} acl {{$key}}-host hdr_beg(host) -i {{$pairs.backends}}. use_backend {{$key}}-servers if {{$key}}-host {{end}}{{end}} {{end}}
feeding HAProxy frontends (in) frontend http-in bind 0.0.0.0:80 mode
http acl api-host hdr_beg(host) -i production.api. use_backend api-servers if api-host
feeding HAProxy backends (server) {{range $key, $pairs := tree
"env/prod/haproxy/sites" | explode }} {{ if $pairs }} backend {{$key}}-servers {{ if eq (or $pairs.mode "http") "http" }} option httpchk {{or $pairs.httpchk "GET /healthz"}} {{ end }} http-response set-header X-App {{$key}} # servers{{$backends := or $pairs.backends "localhost"}} {{range service $backends}} server {{.Node}}_{{.Port}} {{.Address}}: {{.Port}} check {{end}} {{end}} {{end}}
feeding HAProxy backends (server) backend api-servers option httpchk GET
/healthz balance roundrobin http-response set-header X-App api # servers server app141_20081 10.0.0.141:20081 check server app159_20106 10.0.0.159:20106 check
takeaways easy to start using a dynamic env.
takeaways use the k/v store in consul for control.
takeaways It’s fast.
takeaways It’s fun.
takeaways It’s modular.
takeaways keeps us in control.
takeaways correlations.
takeaways uptime.
takeaways Simple, Modular &
Composable
takeaways Simple, Modular &
takeaways Simple, Modular &
Combustible
thank you! questions?