24/11/2016
Docker Workshop - 2nd Day
Orchestrating Docker Containers
Hugo Arraes Henley - hugohenley at id dot uff dot br
1
Agenda
✤ Ecosystem - An overview
✤ Rancher
✤ Mesos
✤ Marathon
✤ Service Discovery
✤ Monitoring Systems
✤ CI and Deploy
Before we start…
✤ Questions: #workshop-docker at Slack
✤ Urgent questions: ask anytime
✤ We will have a break at 15:45~16:00
✤ Today: 80 slides
✤ Check your cellphones3
The Ecosystem
4
The Ecosystem
and more…
5
The Ecosystem
and much more…
7
8
Rancher
✤ Provides a web interface to manage your containers
✤ Helps you to create your own cluster
✤ Helps you to deploy your containerized apps
✤ Natively supports and manages all of your Kubernetes, Mesos, and Swarm clusters.
✤ Easy to install!
sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
https://docs.rancher.com/rancher/v1.2/en/installing-rancher/installing-server/
16
https://speakerdeck.com/jbeda/containers-at-scale
3300 containers/sec
Of course it needs orchestration…
23
Mesos
Mesos
https://www.linux.com/news/4-unique-ways-uber-twitter-paypal-and-hubspot-use-apache-mesos
Mesos at Twitter
https://mesosphere.com/blog/2014/06/11/how-twitter-uses-mesos-video/
“In step (1), slave 1 reports to the master that it has 4 CPUs and 4 GB of memory free. The master then invokes the allocation module, which tells it that framework 1 should be offered all available resources.
In step (2), the master sends a resource offer describing these resources to framework 1.
In step (3), the framework’s scheduler replies to the master with information about two tasks to run on the slave, using ⟨2 CPUs, 1 GB RAM⟩ for the first task, and ⟨1 CPUs, 2 GB RAM⟩ for the second task.
Finally, in step (4), the master sends the tasks to the slave, which allocates appropriate resources to the framework’s executor, which in turn launches the two tasks (depicted with dotted borders). Because 1 CPU and 1 GB of RAM are still free, the allocation module may now offer them to framework 2.”
CREATING A NEW APP…
Nice! But how people can access my app if I have no control about where it is running…?
SERVICE DISCOVERY
44
4 REDIS INSTANCES
SCALING DOWN…
For every new container, a software called registrator sends the list of running containers to the consul server
gliderlabs/registrator
$ docker run -d \ --name=registrator \ --net=host \ --volume=/var/run/docker.sock:/tmp/docker.sock \ gliderlabs/registrator:latest \ consul://localhost:8500
HAPROXY TEMPLATE
http://sirile.github.io/2015/05/18/using-haproxy-and-consul-for-dynamic-service-discovery-on-docker.html
Consul template updates your HAProxy configuration file based on what is running!
That’s why your clients can access your app, no matter where it's running :)
Monitoring
57
“Prometheus collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if some condition is observed to be true.”
https://www.infoq.com/news/2015/12/dockercon-docker-monitoring
https://github.com/vegasbrianc/prometheus
Prometheus References
✤ https://developers.soundcloud.com/blog/prometheus-monitoring-at-soundcloud
✤ https://www.brianchristner.io/how-to-setup-prometheus-docker-monitoring/
✤ https://prometheus.io/docs/instrumenting/exporters/
✤ https://www.infoq.com/news/2015/12/dockercon-docker-monitoring
✤ https://github.com/vegasbrianc/prometheus
✤ https://www.brianchristner.io/updated-docker-monitoring-prometheus-grafana/
✤ https://www.ctl.io/developers/blog/post/monitoring-docker-services-with-prometheus/
65
RECAP
Docker + Mesos + Marathon + Rancher + Consul + Registrator + Consul Template + cAdvisor + Prometheus + Grafana
=
:)
DEPLOYING
YOU WILL NEED A CI
PUTTING EVERYTHING TOGETHER…
registrator
consul-templateDev
User
Docker + Mesos + Marathon + Rancher + Consul + Registrator + Consul Template + cAdvisor + Prometheus + Grafana + Jenkins
=
:)
Remember: there is no silver bullet!
81
Thank you!
82
hugohenley at id dot uff dot br