Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Introction to docker swarm

1.368 Aufrufe

Veröffentlicht am

Introction to docker swarm

Veröffentlicht in: Serviceleistungen
  • Als Erste(r) kommentieren

Introction to docker swarm

  1. 1. Introduction to Docker Swarm Hsi-Kai Wang
  2. 2. Outline • Docker Cluster • Swarm • Swarm + Consul + overlay network
  3. 3. What is PC Cluster • A computer cluster consists of a set of loosely or tightly connected computers that work together so that, in many respects, they can be viewed as a single system. Unlike grid computers, computer clusters have each node set to perform the same task, controlled and scheduled by software. Ref: Computer cluster wiki
  4. 4. Docker Cluster Software • Apchae Mesos – abstract resource • docker swarm – easy way to cluster – standard Docker API • kubernetes – container merge – sample scaling
  5. 5. What is Swarm • Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. Because Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
  6. 6. Software Environment • OS – CentOS: 7 (7.1.1503) • Software – Docker 1.10 (1.10.3.cs2) – Docker container network (Docker >= 1.9) – Swarm (Docker >= 1.5, 2375 port) – Consul
  7. 7. Swarm cluster Docker Host 172.17.33.83 Docker Host 172.17.33.84 Docker Host swarmswarmswarm Docker Host swarm 172.17.33.86 swarm cluster swarm manager swarm node
  8. 8. Docker - Setting• # docker install (Commercially Support, CS) centos:~ # rpm --import https://sks- keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d5 6f59a178ac6c6238f52e centos:~ # yum install yum-utils centos:~ # yum-config-manager --add-repo https://packages.docker.com/1.10/yum/repo/main/centos/7 centos:~ # yum install docker-engine centos:~ # systemctl enable docker.service centos:~ # systemctl start docker.service centos:~ # docker version # check version >= 1.5 • # docker config centos:~ # vi /etc/systemd/system/multi- user.target.wants/docker.serivce ... ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ... centos:~ # systemctl restart docker.service centos:~ # docker pull swarm update setting
  9. 9. Swarm - config • # run once to get swarm token_id centos:~ # docker run --rm swarm create c4602d1cf638ac9805a0693499f04404 • # setup swarm node node:~ # docker run -d swarm join -- advertise=172.17.33.83:2375 token://c4602d1cf638ac9805a0693499f04404 • # setup swarm manager manager:~ # docker run -d -p 2375:2375 swarm manage token://c4602d1cf638ac9805a0693499f04404 • # list swarm cluster manager/node:~ # docker run --rm swarm list token://c4602d1cf638ac9805a0693499f04404 swarm node IP token id
  10. 10. Swarm - usage • # usage 1 manager:~ # docker -H 172.17.33.86:2375 info manager:~ # docker -H 172.17.33.86:2375 run hello-world manager:~ # docker -H 172.17.33.86:2375 ps -a • # usage 2 manager:~ # export DOCKER_HOST=172.17.33.86:2375 manager:~ # docker info manager:~ # docker run hello-world manager:~ # unset DOCKER_HOST swarm manager IP swarm manager IP
  11. 11. Key/Value Server for Docker • Apache ZooKeeper • Consul • etcd
  12. 12. What is Consul • Consul has multiple components, but as a whole, it is a tool for discovering and configuring services in your infrastructure. It provides several key features: – Service Discovery – Key/Value Store – Multi Datacenter – Health Checking
  13. 13. Docker container network • Default Networks – bridge – none – host • User-Defined Networks – bridge – overlay
  14. 14. Default Networks Container eth0 Host eth0 docker0 vethxx Container eth0 Container eth0 bridge network none network host network
  15. 15. User-Defined Networks Container eth0 Host docker_gwbridge vethxx eth1 eth0 Container eth1 Host docker_gwbridge vethxx eth0 eth0 overlay network
  16. 16. Swarm cluster + Consul + overlay network Docker Host 172.17.33.83 Docker Host 172.17.33.84 Docker Host swarmswarmswarm Docker Host swarm 172.17.33.86 swarm cluster swarm manager swarm node consul
  17. 17. Consul • # consul install consul:~ # docker pull progrium/consul consul:~ # docker run -d -p 8500:8500 progrium/consul -server - bootstrap • # consul test consul:~ # curl -L http://172.17.33.86:8500/v1/catalog/nodes consul IP
  18. 18. Docker - Setting • # docker install (Commercially Support, CS) centos:~ # rpm --import https://sks- keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d5 6f59a178ac6c6238f52e centos:~ # yum install yum-utils centos:~ # yum-config-manager --add-repo https://packages.docker.com/1.10/yum/repo/main/centos/7 centos:~ # yum install docker-engine centos:~ # systemctl enable docker.service centos:~ # systemctl start docker.service centos:~ # docker version # check version >= 1.9 • # docker config centos:~ # vi /etc/systemd/system/multi- user.target.wants/docker.serivce ... ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=consul://172.17.33.86:8500 --cluster- advertise=172.17.33.83:2375 ... centos:~ # systemctl restart docker.service centos:~ # docker pull swarm consul IP swarm node IP
  19. 19. Swarm • # setup swarm node node:~ # docker run -d swarm join --advertise=172.17.33.83:2375 consul://172.17.33.86:8500/dc1 • # setup swarm manager manager:~ # docker run -d -p 2376:2375 swarm manage consul://172.17.33.86:8500/dc1 • # list swarm cluster manager:~ # docker run --rm swarm list consul://172.17.33.86:8500/dc1 swarm node IPconsul IP
  20. 20. overlay network • manager:~ # docker network create -d overlay onetwork manager:~ # docker network ls • manager:~ # docker run -itd --name=abc -- env="constraint:node==d1" --net=onetwork ubuntu /bin/bash manager:~ # docker run -itd --name=xyz -- env="constraint:node==d2" --net=onetwork ubuntu /bin/bash manager:~ # docker ps --subnet=10.0.9.0/24 --ip-range=10.0.9.0/24
  21. 21. overlay network • manager:~ # docker network inspect onetwork manager:~ # docker exec -it abc ping -c3 10.0.0.3
  22. 22. Reference • Manually Install the CS Docker Engine • Understand Docker container networks • 深入瞭解 Docker Container Networks • 用Docker Swarm打造多主機叢集環境 • Docker cluster with swarm, consul, registrator and consul-template

×