Stage 4.1: Networking in Swarm with Weave



Managing Swarm Network with Weave


Even with Swarm up and with the network overlay feature of Swarm, we find some problems to get access to the deployed containers. We need a better network layer and there are some interesting projects working in this area:

  1. Flannel: A network layer for Coreos project and use the distributed key value store Etcd. Is a good solution if you use CoreOS. There aren't any option to use Consul as we are using.
  2. Weave: A neutral solution, can be used in Swarm or Kubernetes clusters. Create a bridge between the container and the host and manage communications between the hosts via VxLAN and the hosts itself and own containers.
  3. OpenVswitch: SDN is like a swiss army knife for network management, but need some special effort to run it.

From the three solutions, the second is clearly near to the design. It need a new box (the weave box based in the swarm box) as we did in Stage 3 to raise virtual machines faster.
The third option will be discussed in another stage.





The code to create the weave box is in https://github.com/aescanero/elasticmmldap/tree/base_weave and this is how to package and add the box:


$ git clone -b base_weave https://github.com/aescanero/elasticmmldap base_weave
$ cd base_weave
~/base_weave$ vagrant up
~/base_weave$ vagrant halt
~/base_weave$ vagrant package
~/base_weave$ vagrant box add package.box --name elasticmmldap/base_weave
~/base_weave$ vagrant destroy -f
Looking in what are we doing:




To install weave we only need to download a script called weave from git.io/weave, in the base package we only need the actual versiĆ³n of the script because weave is build upon containers:  router,  manager, dns and proxy, and database.

With the base configured and added to vagrant, is easy to raise the five virtual machines. 

Swarm + Weave Cluster

Inside in each node of the swarm cluster we launch the Weave containers, and then connect each node with the other.

Weave will give us a DNS solution and access from the hosts to any container in any node.

With the command 'weave status', we'll get all the information about the network. Two very important changes with the Swarm stage:

  1. Swarm agent will communicate with Docker service thought a Weave proxy in port 12375 (After weave launch, the proxy is stopped and launched with correct configuration).
  2. Each node will change the default bridge to weave and expose a IP for Weave.
  3. A script will query to consul nodes to connect the Weave nodes each other.







Stage 4 Command Line Execution

These are the steps to raise the virtual machines and the video with full execution.




$ vagrant box remove elasticmmldap/base_docker
$ vagrant box remove elasticmmldap/base_swarm
$ vagrant box remove elasticmmldap/base_weave
$ if [ -d base_docker ];then rm -rf base_docker;fi
$ git clone -b base_docker https://github.com/aescanero/elasticmmldap base_docker
$ cd base_docker
~/base_docker$ vagrant up
~/base_docker$ vagrant halt
~/base_docker$ vagrant package
~/base_docker$ vagrant box add package.box --name elasticmmldap/base_docker
~/base_docker$ vagrant destroy -f
~/base_docker$ cd ..
$ if [ -d base_swarm ];then rm -rf base_swarm;fi
$ git clone -b base_swarm https://github.com/aescanero/elasticmmldap base_swarm
$ cd base_swarm
~/base_swarm$ vagrant up
~/base_swarm$ vagrant halt
~/base_swarm$ vagrant package
~/base_swarm$ vagrant box add package.box --name elasticmmldap/base_swarm
~/base_swarm$ vagrant destroy -f
~/base_swarm$ cd ..
$ if [ -d base_weave ];then rm -rf base_weave;fi
$ git clone -b base_weave https://github.com/aescanero/elasticmmldap base_weave
$ cd base_weave
~/base_weave$ vagrant up
~/base_weave$ vagrant halt
~/base_weave$ vagrant package
~/base_weave$ vagrant box add package.box --name elasticmmldap/base_weave
~/base_weave$ vagrant destroy -f
~/base_weave$ cd ..
$ git clone -b stage4 https://github.com/aescanero/elasticmmldap elasticmmldap_stage4
$ cd elasticmmldap_stage4
~/elasticmmldap_stage4$ vagrant up


A video with the execution:






Some checks:



To clear the lab:
~/elasticmmldap_stage4$ vagrant destroy -f
~/elasticmmldap_stage4$ vagrant box remove elasticmmldap/base_docker
~/elasticmmldap_stage4$ vagrant box remove elasticmmldap/base_swarm
~/elasticmmldap_stage4$ vagrant box remove elasticmmldap/base_weave
All to the code of this lab in: https://github.com/aescanero/elasticmmldap/tree/stage4

Next lab: persistent storage with glusterfs


Comments