VarnaConf - Blue/Green Deployments with Docker, haproxy and Consul
1. Agile and DevOps The Problem The Solution The Demo Q/A
Blue/Green Deployment with HAProxy
and Consul
Автоматизирано въвеждане в експлоатация на софтуер
Владимир Витков
2016.08.13 / VarnaConf
Blue/Green Deployment with HAProxy and Consul Владимир Витков
2. Agile and DevOps The Problem The Solution The Demo Q/A
Кой е пред вас
• Владимир
• Системен Администратор
• Привърженик на FOSS но не и зеалот
• Експериментатор
• Относително приятен човек за разговор*
Blue/Green Deployment with HAProxy and Consul Владимир Витков
3. Agile and DevOps The Problem The Solution The Demo Q/A
Census
• Програмисти
• Администратори
• Performance
• Agile
• QA
Blue/Green Deployment with HAProxy and Consul Владимир Витков
4. Agile and DevOps The Problem The Solution The Demo Q/A
Agile and DevOps
Blue/Green Deployment with HAProxy and Consul Владимир Витков
5. Agile and DevOps The Problem The Solution The Demo Q/A
Какво е Agile
• Идеология за разработка на софтуер
• Това което се ползва
• Нещо прекрасно
• . . . но но съвсем
• Периоди на разработка с функционалност
• Много караници
Blue/Green Deployment with HAProxy and Consul Владимир Витков
6. Agile and DevOps The Problem The Solution The Demo Q/A
Какво е DevOps
• Смесица между администратор и разработчик
• Много автоматизация
• Управлени на инфраструктура
• . . . като разработчик
• Отново много караници
Blue/Green Deployment with HAProxy and Consul Владимир Витков
7. Agile and DevOps The Problem The Solution The Demo Q/A
Защо Agile и DevOps
• Agile - много версии (и често)
• DevOps - мутираща инфраструктура
• Сборът? - голямо натоварване ако няма синхрон
• Бързо развитие на софтуера
Blue/Green Deployment with HAProxy and Consul Владимир Витков
8. Agile and DevOps The Problem The Solution The Demo Q/A
The Problem
Blue/Green Deployment with HAProxy and Consul Владимир Витков
9. Agile and DevOps The Problem The Solution The Demo Q/A
Приложението
Blue/Green Deployment with HAProxy and Consul Владимир Витков
10. Agile and DevOps The Problem The Solution The Demo Q/A
The Solution
Blue/Green Deployment with HAProxy and Consul Владимир Витков
11. Agile and DevOps The Problem The Solution The Demo Q/A
Архитектура
Blue/Green Deployment with HAProxy and Consul Владимир Витков
12. Agile and DevOps The Problem The Solution The Demo Q/A
Компоненти
• docker
• haproxy
• consul
• registrator
Blue/Green Deployment with HAProxy and Consul Владимир Витков
13. Agile and DevOps The Problem The Solution The Demo Q/A
Consul
• Контейнер предоставящ key/value услуга
• Съхранява описанието на приложението ни
• Може да се клъстеризира
Blue/Green Deployment with HAProxy and Consul Владимир Витков
14. Agile and DevOps The Problem The Solution The Demo Q/A
Consul - starting
docker run --detach --restart=always
--hostname consul-master --name consul-master
gliderlabs/consul-server [-bootstrap]
Blue/Green Deployment with HAProxy and Consul Владимир Витков
15. Agile and DevOps The Problem The Solution The Demo Q/A
Registrator
• Динамично обновява Consul
• Попълва параметри за контейнери
Blue/Green Deployment with HAProxy and Consul Владимир Витков
16. Agile and DevOps The Problem The Solution The Demo Q/A
Registrator - starting
docker run --detach --restart=always
--name registrator --hostname registrator
--net=host
--volume=/var/run/docker.sock:/tmp/docker.sock
gliderlabs/registrator:latest consul://localhost:85
Blue/Green Deployment with HAProxy and Consul Владимир Витков
17. Agile and DevOps The Problem The Solution The Demo Q/A
haproxy
• контейнер базиран на alpine linux
• haproxy
• consul-template
• nginx - holding pages
Blue/Green Deployment with HAProxy and Consul Владимир Витков
18. Agile and DevOps The Problem The Solution The Demo Q/A
haproxy - entrypoint
frontend http-in
bind *:80
# Generated automatically by consul-template
# blue if app-web and blue in service/app/color
# green if app-web and green in service/app/color
# else holding
use_backend app_{{with $cl:=key "service/app/color"
default_backend app_holding
Blue/Green Deployment with HAProxy and Consul Владимир Витков
19. Agile and DevOps The Problem The Solution The Demo Q/A
haproxy - holding
backend web_holding
server sink 127.0.0.1:59599
Blue/Green Deployment with HAProxy and Consul Владимир Витков
20. Agile and DevOps The Problem The Solution The Demo Q/A
haproxy - color
listen web_green
bind *:18000
balance roundrobin
{{range $i,$s:=service "web"}}
{{if .Tags | contains "green"}}
server {{$i}}{{.Node}}green {{.Address}}:{{.Port}}
{{end}}
{{end}}
server sink 127.0.0.1:56569 backup
Blue/Green Deployment with HAProxy and Consul Владимир Витков
21. Agile and DevOps The Problem The Solution The Demo Q/A
haproxy - starting
docker run --detach --restart=always
--env=’CONSUL_CONNECT=172.17.42.1:8500’
--hostname lb-prod --name lb-prod
zeridon/haproxy-consul
Blue/Green Deployment with HAProxy and Consul Владимир Витков
22. Agile and DevOps The Problem The Solution The Demo Q/A
The Demo
Blue/Green Deployment with HAProxy and Consul Владимир Витков
23. Agile and DevOps The Problem The Solution The Demo Q/A
Q/A
Blue/Green Deployment with HAProxy and Consul Владимир Витков
24. Agile and DevOps The Problem The Solution The Demo Q/A
Контакти
• Владимир Витков
• vvitkov@linux-bg.org
• https://www.getoto.net/zeridon
• https://github.com/zeridon
• http://www.slideshare.net/zeridon
Blue/Green Deployment with HAProxy and Consul Владимир Витков