IPVS for Docker Containers
Andrey Sibiryov
Bulldozer Operator at Uber
This guy on the stage
2
…who the hell are you and why should we believe
a Russian?
What is IPVS
…and why didn’t we hear about it before?
International Pig Veterinary Society
4
IP Virtual Server
5
IP Virtual Server
6
…and why didn’t we hear about it before?
IP Virtual Server
7
Works inside the Linux Kernel, based on
Netfilter.
Supports TCP, SCTP & UDP, v4 and v6.
8+ methods: WRR, WLC, LBLCR, SH
and much more – plugins.
NAT, Tunneling, Direct Routing.
Address bundling via FWMark services.
Most importantly, it is bloody fucking fast!
IP Virtual Server
8
…and a little bit more about these weird acronyms.
IPIP
Encapsulates IP
Routable anywhere
NAT
Rewrites DST IP
Same L4
DSR
Rewrites DST MAC
Same L2
IP Virtual Server
9
…and a few more words about DR since it’s awesome!
TPS
50
66
82
98
114
130
Single IPVS DR HAProxy MySQL Proxy
I don’t need this
10
…and why would we load balance and route
anything at all?
I don’t need this
11
…also, our nginx, haproxy, hipache, vulcand
setup works fine – get off the stage, please!
I don’t need this
12
…and we run our stuff in the cloud, it takes care of
everything – our work is perpetual siesta!
IP Virtual Server
13
IPVS NGINX HAPROXY AWS ELB
OSI layer L4 L7 L7 L4
TCP ✅ ℹ ✅ ✅
UDP ✅ 🚫 🚫 🚫
Dynamic
configuration ✅ 🚫 ℹ ✅
Forwarding
methods 4 NAT NAT NAT
Balancing
methods 8+ 3 6 RR
Health checks ✅ 🚫 ✅ ✅
What is IPVS
…and how do we use it since it sounds so amazing!
GORB
15
Go Routing and Balancing
github.com/kobolog/gorb
What is GORB
16
…and why is it cool for Docker Containers?
17
REST API daemon to control IPVS.
Simple GET, PUT, DELETE interface.
Docker Link to control GORB.
TCP, HTTP health checks built-in.
Written in Go, LGPL licensed, on GitHub.
Docker + GORB + MacVLAN network
plugin + IPVS DR forwarding mode = ❤
What is GORB
…and why is it cool for Docker Containers?
What is GORB
…and how do we use it? Live demo or GTFO!
What is GORB
19
The guy on the stage is doing roughly this right now.
kobolog@gorb:~$ go install github.com/kobolog/gorb
kobolog@gorb:~$ sudo modprobe ip_vs
kobolog@gorb:~$ sudo gorb &
kobolog@docker:~$ go install github.com/kobolog/gorb/gorb-docker-link
kobolog@docker:~$ export DOCKER_HOST=<...>
kobolog@docker:~$ gorb-docker-link -r gorb:4672 &
kobolog@docker:~$ docker run -d -p 80 nginx
kobolog@gorb:~$ curl -i -XGET http://localhost:80
A few more words about BGP
20
…black belt in networking is not complete without
a few words about BGP.
How stable is GORB
21
…and is it production-ready? Can we blame you if
it doesn’t work?
«I'll let you in on a secret: my
pet hamster did all the coding.
I was just a channel, a «front»
if you will, in my pet's grand
plan. So, don't blame me if
there are bugs. Blame the
cute, furry one» —Rusty Russel
22
€25,000
23
…is the price for an enterprise hardware load-
balancer.
€0
24
…is a price for IPVS and BGP (and GORB).
Works on commodity hardware.
No special software or tools, no SNMP.
1000-word man page vs. 1000-page
vendor manual.
1 GBPS line rate = 1% CPU in DR mode.
IPVS is around for more than 15 years.
25
A good way to spend €25,000
Thank you!
Andrey Sibiryov
@kobolog
me@kobology.ru

Kernel load-balancing for Docker containers using IPVS

  • 1.
    IPVS for DockerContainers Andrey Sibiryov Bulldozer Operator at Uber
  • 2.
    This guy onthe stage 2 …who the hell are you and why should we believe a Russian?
  • 3.
    What is IPVS …andwhy didn’t we hear about it before?
  • 4.
  • 5.
  • 6.
    IP Virtual Server 6 …andwhy didn’t we hear about it before?
  • 7.
    IP Virtual Server 7 Worksinside the Linux Kernel, based on Netfilter. Supports TCP, SCTP & UDP, v4 and v6. 8+ methods: WRR, WLC, LBLCR, SH and much more – plugins. NAT, Tunneling, Direct Routing. Address bundling via FWMark services. Most importantly, it is bloody fucking fast!
  • 8.
    IP Virtual Server 8 …anda little bit more about these weird acronyms. IPIP Encapsulates IP Routable anywhere NAT Rewrites DST IP Same L4 DSR Rewrites DST MAC Same L2
  • 9.
    IP Virtual Server 9 …anda few more words about DR since it’s awesome! TPS 50 66 82 98 114 130 Single IPVS DR HAProxy MySQL Proxy
  • 10.
    I don’t needthis 10 …and why would we load balance and route anything at all?
  • 11.
    I don’t needthis 11 …also, our nginx, haproxy, hipache, vulcand setup works fine – get off the stage, please!
  • 12.
    I don’t needthis 12 …and we run our stuff in the cloud, it takes care of everything – our work is perpetual siesta!
  • 13.
    IP Virtual Server 13 IPVSNGINX HAPROXY AWS ELB OSI layer L4 L7 L7 L4 TCP ✅ ℹ ✅ ✅ UDP ✅ 🚫 🚫 🚫 Dynamic configuration ✅ 🚫 ℹ ✅ Forwarding methods 4 NAT NAT NAT Balancing methods 8+ 3 6 RR Health checks ✅ 🚫 ✅ ✅
  • 14.
    What is IPVS …andhow do we use it since it sounds so amazing!
  • 15.
    GORB 15 Go Routing andBalancing github.com/kobolog/gorb
  • 16.
    What is GORB 16 …andwhy is it cool for Docker Containers?
  • 17.
    17 REST API daemonto control IPVS. Simple GET, PUT, DELETE interface. Docker Link to control GORB. TCP, HTTP health checks built-in. Written in Go, LGPL licensed, on GitHub. Docker + GORB + MacVLAN network plugin + IPVS DR forwarding mode = ❤ What is GORB …and why is it cool for Docker Containers?
  • 18.
    What is GORB …andhow do we use it? Live demo or GTFO!
  • 19.
    What is GORB 19 Theguy on the stage is doing roughly this right now. kobolog@gorb:~$ go install github.com/kobolog/gorb kobolog@gorb:~$ sudo modprobe ip_vs kobolog@gorb:~$ sudo gorb & kobolog@docker:~$ go install github.com/kobolog/gorb/gorb-docker-link kobolog@docker:~$ export DOCKER_HOST=<...> kobolog@docker:~$ gorb-docker-link -r gorb:4672 & kobolog@docker:~$ docker run -d -p 80 nginx kobolog@gorb:~$ curl -i -XGET http://localhost:80
  • 20.
    A few morewords about BGP 20 …black belt in networking is not complete without a few words about BGP.
  • 21.
    How stable isGORB 21 …and is it production-ready? Can we blame you if it doesn’t work?
  • 22.
    «I'll let youin on a secret: my pet hamster did all the coding. I was just a channel, a «front» if you will, in my pet's grand plan. So, don't blame me if there are bugs. Blame the cute, furry one» —Rusty Russel 22
  • 23.
    €25,000 23 …is the pricefor an enterprise hardware load- balancer.
  • 24.
    €0 24 …is a pricefor IPVS and BGP (and GORB). Works on commodity hardware. No special software or tools, no SNMP. 1000-word man page vs. 1000-page vendor manual. 1 GBPS line rate = 1% CPU in DR mode. IPVS is around for more than 15 years.
  • 25.
    25 A good wayto spend €25,000
  • 26.