Git Product home page Git Product logo

ansible-docker-swarm-cluster's Introduction

Ansible Docker Swarm Cluster

Create and deploy an n-node docker swarm cluster in minutes, with Traefik as a reverse proxy and load balancer, Portainer to manage containers and Jenkins as a CI/CD solution (this is a customized Jenkins docker image whose Jobs can interact with docker).

Prerequisites

  • One or more servers running Ubuntu 20.04 connected through a private network (tests were done using GCP).
  • Ansible.
  • SSH access to these servers using your public key (you can achieve this by simply using ssh-copy-id <hostname>).

Preparation

First clone this repo to your local machine

git clone https://github.com/rodrigoegimenez/ansible-docker-swarm-cluster.git
cd ansible-docker-swarm-cluster

Then edit the hosts file by replacing the ip of your main server and replacing/adding as many nodes as you wish to join your server (if just starting you can just have your main server and add nodes later on). Then create an extra-vars.yml using the example as a guide.

Running

Once finished editing your hosts file you can run all the required commands using the provided Makefile that will launch the appropiate playbook:

make swarm-cluster

This command will start running the imported playbooks in the order they appear:

- import_playbook: docker-dependencies.yml
- import_playbook: main.yml
- import_playbook: workers.yml
- import_playbook: traefik/traefik.yml
- import_playbook: portainer/portainer.yml
- import_playbook: jenkins/jenkins.yml

After a couple minutes the cluster will be up and initialized and ansible will start to install traefik and the other services asking a prompt for user, password and email (for traefik), and for the domain names for all three services (to use with traefik reverse proxy). Make sure you point these (sub)domains to the main's public ip address.

A couple of more minutes and you should have your cluster up and running.

Acknowledgement

This idea is heavily influenced by Docker Swarm Rocks. Traefik and portainer's compose files were obtained from this guide.

Another source of inspiration, specially for the ansible part, was this DigitalOcean's guide to create a Kubernetes Cluster.

ansible-docker-swarm-cluster's People

Contributors

rodrigoegimenez 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.