DEV Community

Cover image for The 5 minute cluster
Rodrigo Gimenez
Rodrigo Gimenez

Posted on

The 5 minute cluster

ansible-playbook -i hosts swarm-bootstrap.yml  61,38s user 14,61s system 25% cpu 5:00,57 total
Enter fullscreen mode Exit fullscreen mode

Being a DevOps enthusiast I am always looking forward to testing and studying new tech as I discover them. On top of that being a Linux user for more than 20 years has made me savvy to know how stuff work to the very basic.

This time I wanted to build and play around with a docker-powered cluster. Initially the idea was to play around with Kubernetes but it's a beast I am yet to tame. So I moved to a simpler solution: docker swarm.

Inspired by Docker Swarm Rocks site and a Digital Ocean's Guide, I created a set of ansible playbooks that automate the process of installing and configuring the cluster including Traefik as reverse proxy, Portainer as container manager and Jenkins as an automation server.

To run this you will need, first, a set of Linux Servers (VM or Bare Metal). You should have ansible installed, and ssh access to each of these servers. In my case I used Google Cloud Platform's Instances to do all the testing.

Once you have all your servers set up, including ssh access to them, clone the repo to your local machine,

git clone https://github.com/rodrigoegimenez/ansible-docker-swarm-cluster.git
cd ansible-docker-swarm-cluster
Enter fullscreen mode Exit fullscreen mode

Add your servers info to the hosts file, and finally run the main playbook,

ansible-playbook -i hosts swarm-bootstrap.yml
Enter fullscreen mode Exit fullscreen mode

sit back and relax. When installing the services ansible will ask you questions like the domain to use (ie. traefik.yoursite.com) and credentials for some of these services. Make sure you are pointing these domains to the master node of your cluster.

In 5 minutes you'll have your cluster up and running and ready to deploy more and more services to.

That's it!

Photo by James Wainscoat on Unsplash

Top comments (0)