Docker Swarm and Flocker are evolving technologies & I was trying to integrate them but there was some lack of documentation efforts & really its challenge to integrate these two technologies. After putting lots of integration efforts I came up with useful configuration steps.
First of all, let’s check the background of these technologies – Docker Swarm is the cluster management tool for the Docker containers. Docker Swarm provides native clustering capabilities to turn a group of Docker engines into a single node.
Flocker is an open-source container data volume manager for your Dockerized applications. Flocker manages Docker containers and data volumes together. Flocker allows you to use external persistent storage and move it between containers using Docker Swarm.
Docker Swarm & Flocker Driver integration Steps
1. Check Status Flocker Node list
root@flockerdev1-virtual-machine:/home/flocker-dev1# flockerctl list-nodes SERVER ADDRESS 53bbc30e 172.17.58.212 295aabcd 172.17.58.211 root@flockerdev1-virtual-machine:/home/flocker-dev1# |
2. Check Flocker Volume list
root@flockerdev1-virtual-machine:/home/flocker-dev1# flockerctl ls DATASET SIZE METADATA STATUS SERVER root@flockerdev1-virtual-machine:/home/flocker-dev1# |
3. Create a Flocker Volume
root@flockerdev1-virtual-machine:/home/flocker-dev1# docker volume create --driver flocker --name yp-pune -o size=1GB yp-pune root@flockerdev1-virtual-machine:/home/flocker-dev1# |
4. Now again Check Flocker Volume list
root@flockerdev1-virtual-machine:/home/flocker-dev1# flockerctl ls /usr/local/bin/flockerctl: 3: read: Illegal option -d DATASET SIZE METADATA STATUS SERVER 938e66cf-95ef-4131-9c3a-52c0fe5236e5 1.00G maximum_size=1073741824,name=yp-pune attached ✅ 295aabcd (172.17.58.211) root@flockerdev1-virtual-machine:/home/flocker-dev1# |
5. Check the Swarm Cluster Node status
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker node list ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 3c4w4zvcyzmwhrr0mrxfkc5pf * flockerdev1-virtual-machine Ready Active Leader 4j8ir0rya0x3nh068xxbct4z6 flockerdev2-virtual-machine Ready Active root@flockerdev1-virtual-machine:/home/flocker-dev1# |
6. Now create a Swarm Service
root@flockerdev1-virtual-machine:/home/flocker-dev1# docker service create --mount type=volume,source=yp-pune,target=/Calsoft --name yogesh centos sh -c 'while true; do touch /Calsoft/$(hostname)-$(date +%F-%T); sleep 5; done' 0pdnne9urig6kp23130hrp285 root@flockerdev1-virtual-machine:/home/flocker-dev1# |
7. Check status of Swarm Service
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker service ls ID NAME REPLICAS IMAGE COMMAND 0pdnne9urig6 yogesh 1/1 centos sh -c while true; do touch /Calsoft/$(hostname)-$(date +%F-%T); sleep 5; done root@flockerdev1-virtual-machine:/home/flocker-dev1# |
8. Find out on which node service is running
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker service ps yogesh ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR 1nowf2k2zmjv79zkdk9m3ewh6 yogesh.1 centos flockerdev1-virtual-machine Running Running about a minute ago root@flockerdev1-virtual-machine:/home/flocker-dev1# |
9. Check the IO on the Flocker volume
root@flockerdev1-virtual-machine:/home/flocker-dev1# ls /flocker/938e66cf-95ef-4131-9c3a-52c0fe5236e5 c8e89ca73b93-2016-09-22-09:59:53 c8e89ca73b93-2016-09-22-10:00:38 c8e89ca73b93-2016-09-22-10:01:24 c8e89ca73b93-2016-09-22-10:02:09 c8e89ca73b93-2016-09-22-09:59:58 c8e89ca73b93-2016-09-22-10:00:43 c8e89ca73b93-2016-09-22-10:01:29 c8e89ca73b93-2016-09-22-10:02:14 c8e89ca73b93-2016-09-22-10:00:08 c8e89ca73b93-2016-09-22-10:00:54 c8e89ca73b93-2016-09-22-10:01:39 root@flockerdev1-virtual-machine:/home/flocker-dev1# |
10. Now trigger the failure on the active Swarm Node
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker node update --availability drain flockerdev1-virtual-machine flockerdev1-virtual-machine root@flockerdev1-virtual-machine:/home/flocker-dev1# |
11. Now Check the Swarm Node status
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker node list ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 3c4w4zvcyzmwhrr0mrxfkc5pf * flockerdev1-virtual-machine Ready Drain Leader 4j8ir0rya0x3nh068xxbct4z6 flockerdev2-virtual-machine Ready Active root@flockerdev1-virtual-machine:/home/flocker-dev1# |
12. Now Check the Swarm Service Status
root@flockerdev1-virtual-machine:/home/flocker-dev1# sudo docker service ps yogesh ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR 0kb2mmgmzvmiqyx2krigo2j09 yogesh.1 centos flockerdev2-virtual-machine Running Starting 52 seconds ago 1nowf2k2zmjv79zkdk9m3ewh6 \_ yogesh.1 centos flockerdev1-virtual-machine Shutdown Shutdown 55 seconds ago root@flockerdev1-virtual-machine:/home/flocker-dev1# |
14. Now Check the volume status in flockerctl [Volume & Containers are automatically migrated to other active node]
root@flockerdev1-virtual-machine:/home/flocker-dev1# flockerctl ls /usr/local/bin/flockerctl: 3: read: Illegal option -d DATASET SIZE METADATA STATUS SERVER 938e66cf-95ef-4131-9c3a-52c0fe5236e5 1.00G maximum_size=1073741824,name=yp-pune attached ✅ 53bbc30e (172.17.58.212) root@flockerdev1-virtual-machine:/home/flocker-dev1# |
15. Now Check IO on the Flocker volume [IO is continued from the other active node on the same Flocker volume]
root@flockerdev2-virtual-machine:/home/flocker-dev1# ls /flocker/938e66cf-95ef-4131-9c3a-52c0fe5236e5 c8e89ca73b93-2016-09-22-09:59:53 c8e89ca73b93-2016-09-22-10:00:38 c8e89ca73b93-2016-09-22-10:01:24 c8e89ca73b93-2016-09-22-10:02:09 c8e89ca73b93-2016-09-22-09:59:58 c8e89ca73b93-2016-09-22-10:00:43 c8e89ca73b93-2016-09-22-10:01:29 c8e89ca73b93-2016-09-22-10:02:14 5cc6b2b33d59-2016-09-22-10:10:10 c8e89ca73b93-2016-09-22-10:00:23 c8e89ca73b93-2016-09-22-10:01:44 c8e89ca73b93-2016-09-22-10:03:04 5cc6b2b33d59-2016-09-22-10:10:19 c8e89ca73b93-2016-09-22-10:00:28 c8e89ca73b93-2016-09-22-10:01:49 c8e89ca73b93-2016-09-22-10:03:09 |
Using these steps we can easily access Flocker Volumes in the Swarm Docker Cluster. Hope this document will helps you.
Container Ecosystem Services
Calsoft has deep expertise in containerization of Storage and Networking products. With our in-depth understanding of various containerization technologies like Docker, Kubernetes, Apache Mesos and Coreos, we have helped ISVs to design and develop solutions in and around these technologies.
To know more email: marketing@calsoftinc.com
Thanks, great article. It’s really helpful.