Giter Club home page Giter Club logo

ha-vagrant-swarm's Introduction

Docker Swarm Vagrant Ansible

This is a simple deployment of a high available application.

Docker Swarm

Docker Swarm is a Docker clustering solution, it turns multiple physical (or virtual) hosts into a one cluster, which practically behaves as a single Docker host. Swarm additionally gives you tools and mechiasms to easily scale your containers and create managed services with automatic load balancing to the exposed ports.

Swarm uses Raft Consensus Algortihm to manage the cluster state. Swarm can tolerate (N-1)/2 failures and needs (N/2)+1 nodes to agree on values.

Dependencies

  • Ansible
  • Vagrant

Deployment

ansible-playbook -i inventory deploy.yml

Destroy(ment)

vagrant destroy -f

Behaviour

The cluster provides an API call to http:///app When a POST request is sent to that API method, the application will store the timestamp into a database.

Usage

curl -X POST http://192.168.10.2/app

Expected output:

{
  "epoch": 1510659852.600444,
  "hostname": "ca425c25b7a9",
  "records": 3,
  "status": "saved",
  "timestamp": "2017-11-14 11:44:12"
}

Docker container

The container that is deployed in the workers is build with the files that are in the folder container and published to http://cloud.docker.com/ from where is picked by the swarm to run it on the workers.

Technologies

  • Ansible
  • Vagrant
  • VirtualBox
  • Ubuntu
  • Docker
  • Flask
  • Python
  • Redis

Customization

By default, 3 machines are created: manager, worker1, worker2. You can adjust how many workers you want in the Vagrantfile, by setting the numworkers variable. Manager, by default, has address "192.168.10.2", workers have consecutive IPs.

numworkers = 2

If your provisioner is VirtualBox, you can modify the vm allocations for memory and cpu by changing these variables:

vmmemory = 512
numcpu = 1

License

MIT

Author

Sergiu Marsavela @marsavela

ha-vagrant-swarm's People

Contributors

marsavela avatar

Watchers

James Cloos avatar  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.