Docker and Service Discovery KAL Information Services Email
- Slides: 10
Docker and Service Discovery KAL Information Services Email kirk. kalvar@kailinfosvcs. com Phone 703 -628 -7677
Introduction • Enterprise/Mobile/Infrastructure Professional • Motivation: Learn Docker and Docker Orchestration
Problem • Docker Swarm and Docker Compose allow you to scale services, but it doesn’t provide a way to share information about those services. • Example: How do you tell a load balancer you just added or removed a web server?
Solution • Use registrator, consul, and consul-template to scale a web service dynamically
Architecture Swarm Cluster consul swarm master swarm node lb consul template consul web web registrator /var/run/docker. sock
Nginx Consul Template consul-template -consul=$CONSUL_URL -template="/templates/default. ctmpl: /etc/nginx/conf. d/default. conf: service nginx reload“ ------------------------------------------------------------------------/templates/default. ctmpl {{$app : = env "APP_NAME"}} upstream {{printf $app}} { least_conn; {{range service $app}} server {{. Address}}: {{. Port}} max_fails=3 fail_timeout=60 weight=1; {{end}} } server { listen 80 default; location / { proxy_pass http: //{{printf $app}}; } } ------------------------------------------------------------------------/etc/nginx/conf. d/default. conf upstream dockerlb_web { least_conn; server 192. 168. 99. 104: 32768 max_fails=3 fail_timeout=60 weight=1; } server { listen 80 default; location / { proxy_pass http: //dockerlb_web; } }
Quick Demo
Additional Work • • Local Registry (Completed) Health Check (Completed) Reschedule Container on Node Failure (Completed) Performance • Local Registry vs. Docker Hub • Docker Machine provisioning • Auto Scaling
Questions?
References • github. com/hashicorp/consul-template • github. com/gliderlabs/registrator • github. com/kskalvar/docker-lb