Giter Site home page Giter Site logo

heartshare / lsyncd_swarm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkaform/lsyncd_swarm

0.0 0.0 0.0 31 KB

A Lsyncd configuration for Docker Swarm. It enabled the sync of volumes across docker swarm nodes!

License: GNU General Public License v3.0

Dockerfile 7.49% Shell 92.51%

lsyncd_swarm's Introduction

#Distributed Volume Storage for SWARM

The DVS for Swarm is a small and practical service (based on lsyncd using rsync) for distributed storage on SWARM.

The Problem

For regular volumes using swarm, or at least how I could configure it ond figure out. I coudn't find a way, except using a solution with Amazon or Google, to sincronize volume between Docker SWARM nodes.

I did sevreal testing, but when the volume was shared on containers but across diferent nodes, the conteiners could not see the info of the node on their side. Many of the volume dirvers I saw were depricated or weren't open source.

So I decided to do a Docker Swarm service that can help us with.

The Solution

The services run under Alpine Linux and is base on lsyncd . Lsyncd is a mirror soluction. As explained on https://axkibe.github.io/lsyncd/ lsync tha uses a filesystem event interface (inotify or fsevents) to watch for changes to local files and directories. Lsyncd collates these events for several seconds and then spawns one or more processes to synchronize the changes to a remote filesystem. The default synchronization method is rsync. Thus, Lsyncd is a light-weight live mirror solution. Lsyncd is comparatively easy to install and does not require new filesystems or block devices. Lysncd does not hamper local filesystem performance.

Axel Kittenberger (https://github.com/axkibe) comments that Lsyncd is useful for slowly changing sistem, not a database fast data system. So think of the DVS for Swarm as that. For keeping files sync, example profile pictures, shared files, any media, etc. It will sync like a master to master no mater the topology of your solution, it will automaicaly adjust to it as you number of nodes expand or contract.

DVS Swarm is installed as a service directly on the ymal or yml use to diploy your stack.

Requierments, whats needed???

You will need to set this prior requierments for it to work

  • Create an overlay network under swarm called csi_network.

docker network create -d overlay csi_lsyncd

  • Set you secrets. Delcare them under the secret secction on you docker-stack.yml. If you don't decalte them, DVS Swarm will use the defautl, but this is not encurate to do on a production server. So set this secrets and they will be replace with the default ones.

secrets: - id_rsa_lsyncd - authorized_keys_lsyncd

  • Declare on the Volume section and Attache the all the media volume you wish to sync and the docker socket.

volumes: your_media: db-volume:

volumes: - /var/run/docker.sock:/var/run/docker.sock - your_media:/srv/lsyncd_swarm/volumes/your_media

  • Set ports. By default it uses the 7029, but you can change it to whatever you'll like, is just used for the ssh connection.

ports: - 7029

  • Set environment variables. For now we only use 3.

  • SYNC_VOLUMES: Where you will list all the volumes to sync separated by a space.

  • MODE: ALWAYS use swarm, I use other than that like compose for deguggin and testing.

  • HEARTBEAT: Time expresed on seconds, that DVS Swarm will look for new peers.

  • Always use ** mode: global **, or at least if you what to sync the node closter. But you can configurate it to use it only on sertain lables or node conditions.

deploy: mode: global

Example:

services: lsyncd: image: linkaform/lsyncd_swarm:latest networks: - csi_lsyncd environment: SYNC_VOLUMES: infosync_media MODE: swarm HEARTBEAT: 25 ports: - 7029 volumes: - /var/run/docker.sock:/var/run/docker.sock - infosync_media:/srv/lsyncd_swarm/volumes/infosync_media command: /srv/lsyncd_swarm/scripts/make_configuration.sh secrets: - id_rsa_lsyncd - authorized_keys_lsyncd deploy: mode: global update_config: parallelism: 2 delay: 5s restart_policy: condition: on-failure

you_other_service_here:

Disclaimer

Besides the usual disclaimer in the license, we want to specifically emphasize that neither the authors, nor any organization associated with the authors, can or will be held responsible for data-loss caused by possible malfunctions of DVS Swarm.

lsyncd_swarm's People

Contributors

josepato avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.