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
36
Choosing your scheduler wisely
cldmnky
1
130
Other Decks in Technology
See All in Technology
AIがGISを代替する日:〜すべてをAIが創る時代に、私たちがFOSS4Gに関わる意味〜
lehupa
1
210
顧客合意を取りながら進めるAWSコスト削減の実践
optim
0
150
長い仕事を任せる (Workflows、クラウドセッション、Kiro Web) | 目指せ Kiro マスター 10
inariku
PRO
3
140
Kiro IDE 入門 (画面の各部から、頼み方、任せ方、戻し方まで) | 目指せ Kiro マスター 02
inariku
PRO
4
160
The Author Pays
hiccupps
0
140
会社説明資料_最新版
demaecan
0
32k
AIコーディングはじめました
miso
0
160
AWSを利用する上で知っておきたい名前解決の話 2026
nagisa53
5
3.3k
AI時代における医療情報システムのセキュリティ / Security of Healthcare IT Systems in the AI Era
henryofficial
0
120
Claude Codeで作ったアプリを安全に公開する/Built with Claude Japan 2026
yoshidashingo
0
210
Reticulum, le réseau cypherpunk dont vous avez besoin !
rlifchitz
0
110
詳解 never 型 - ボトム型の性質を深掘り
nealle
0
160
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
350
Designing Experiences People Love
moore
143
24k
Paper Plane
katiecoart
PRO
5
55k
New Earth Scene 8
popppiees
4
2.8k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
590
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
エンジニアに許された特別な時間の終わり
watany
109
250k
The agentic SEO stack - context over prompts
schlessera
0
1k
Product Roadmaps are Hard
iamctodd
55
13k
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?