First things first
In this guide I will show you how to setup Docker Swarm. I found this as an alternative to usign K3S after wanting to rip my hair out after 5 days of trying to set it up and it failing every time. Docker Swarm is intuitive compared to Kubernetes yet you achive much of the same goal.
what is the goal?
- My goal in this is to cluster multiple HA servers when deploying a new website for the company I work for. I wanted to challenge myself to push for production ready fault tolerance and HA clustering. My first thought reasonably was Kubernetes, however Kubernetes would fail at some point for me every time.
why does Kubernetes suck?
I was using KVM/Debian machines and every time I attempted to link together more than 1 Master node it would break. I found 15 minutes after finally getting it working that this was not going to be a viable option to deploy for production. There was no way I could trust something that took me 5 days of configuring out in the wild. So I detroyed my Kubernetes cluster and scanned through the documentation of Docker Swarms, something I had heard of but never been hands on with, and managed to get exactly what I wanted in under 15 minutes. High availability, load balancing, all the fancy production ready keywords.
Setup Instructions:
3 Linux VM's
virtualize, bare metal, whatever
I am personally using more than 3 in my actual clusters but I recommend to start with at least 2 to get the concept of networking together the machines
==========================
1st Node MASTER 10.1.9.74:
==========================
docker swarm init --advertise-addr <MANAGER-IP>
docker node ls
To add a worker to this swarm, run the following command:
docker swarm join --token YOURTOKENHERE 10.1.9.74:2377docker service create --replicas 2 --name svb-web -p 3000:3000 ljis120301/svb-web--------------------------------------------------------------------------------------
=========================
Client Setup Script(ish):
=========================
Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world
docker swarm join --token SWMTKN-1-69vlcqj5wcbh90tg7zyglltx0e59j6gcxfp5lmsomqsybsxf7s-98vuozyuth7d7kl9to2cn3f31 10.1.9.74:2377wrapping up:
Just like that Docker Swarm is configured and ready to go, easy as that. After suffering through Kuberentes I am so thankful something like docker swarm exists and is a reliable and repeatable solution. Giving heavy shade to the K3S team for making software that looks easy and then swallows you and fucks you. You know K3S you could at least take me to dinner first before you fuck me.

