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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Transcript
62 slides
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?
More Decks by cldmnky
See All by cldmnky
Customizing and scaling Kubernetes for News
cldmnky
1
40
Choosing your scheduler wisely
cldmnky
1
130
Other Decks in Technology
See All in Technology
Metadata - Section 4 : MODS (Metadata Object Description Schema )
mohab1
0
180
データ界隈LT祭の運営のふりかえり
yoshimura_datam
0
110
AI時代のTechLeadの問い〜Tech Lead Conference 2026 Autumn / questions-for-tech-leads-in-the-age-of-ai
haru860
0
100
新規事業開発でのAWS活用成功談&失敗談! 〜新規事業開発を専門に行うRelicならではのAWS活用〜
amixedcolor
1
160
「個社」ではなく「業界」の課題を解く AI 対話開発 ー 価値を広げる設計と、価値を守るエンジニアリング ー
ivry_presentationmaterials
4
920
コーディングできない僕にBobが舞い降りた
shumpei3
0
230
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
130
Kiro のリモートワークスペース: IDE は手元のままで、ワークスペースをクラウド、コンテナ、自前のマシンに置く
inariku
PRO
2
260
Agent Routerで作るマルチテナント 推論基盤 #CNDW2026 / Building Multi-Tenant Inference Platform with Agent Router #CNDW2026
everpeace
5
650
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.5k
AIフレンドリーなGenerative UIをJSXで
uhyo
2
880
Kiro Crew の Conductor mode: 1 つのチャットに渡したゴールを、コンダクターがワーカーに分けて任せる
inariku
PRO
1
140
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
250
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
640
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Crafting Experiences
bethany
1
460
Design in an AI World
tapps
1
400
Mind Mapping
helmedeiros
1
460
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
My Coaching Mixtape
mlcsv
0
400
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Leo the Paperboy
mayatellez
11
2.5k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340