/demo-docker_swarm

Primary LanguageShellGNU General Public License v3.0GPL-3.0

Setup a Docker Swarm cluster with arbitrary number of nodes

  • Provisioned by ansible

  • Using public ansible roles

Notes

  • Current Vagrant file use virtualbox provisioner for demo purposes . Change to any other provisioner by changing configuration file
  • When running the swarm fot the first time it can take a while to download all necessary images to the nodes.

Setup

  • Change ansible.cfg to match your local setup

  • Change hosts.yml with your desired configuration . In each node #Cpus, memory and role can be configured

  • One private network is used (192.168.33.0/24 ). Change it (on Vagrantfile and hosts.yaml ) if conflicts with existing ones.

      ------------------------------------------ 192.168.33.0/24 network
      |        |            |        |       |
    

| manager1 | | manager2 | | manager3 | | worker1 | | worker2 |

                              ^

| Vagrant |

Dependencies

Usage

  • Create the cluster This Command just creates the cluster without any services running
vagrant up
  • Update the cluster (Optional) to add nodes just edit the file hosts.yaml and run the command again.

Launch defined services

There is one examples directory . Choose one by number .

export EX_NUM="<some_example_configuration_filenumber_in_examples_directory>"
ansible-playbook  \
  -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory \
  --extra-vars='swarm_manager_ip=192.168.33.20' \
  --extra-vars="example_number=$EX_NUM" \
   ansible/playbooks/swarm_run.yml

All services are defined using ansible_docker_swarm role. Check examples

License

GPL 3.0

Author Information

Created by Miguel Rodrigues.