How to use Docker Swarm with HCS.
Docker Swarm
A guide on how to use Docker Swarm with HCS.
Setup in HCS
If you would like to use a Swarm to deploy your resources, you need to add the Swarm Manager
to HCS.
Optionally, you can add the Swarm Workers
to HCS. This will allow HCS to do cleanups and other stuff on the Swarm Workers
.
Docker Registry
You need to have an external Docker Registry available to use the a Swarm, as all workers need to be able to pull the images you built with HCS.
The Swarm Manager needs to push the image to the Docker Registry.
The Swarm Workers need to pull the image from the Docker Registry.
So set your docker login credentials accordingly. More information here.
Install Swarm Cluster
WIP This is just a brief guide to install a simple Docker Swarm cluster. For more information, please refer to the official documentation.
Prerequisites
I will use Hetzner (referral link) for this guide. You can use any other provider.
You need at least 3 servers to create a Docker Swarm cluster with the same architecture (ARM or AMD64).
1 server for the manager node.
2 servers for the worker nodes (you can add more worker nodes if you want).
Add private networking to all servers if possible.
Install Docker
Install Docker on all servers. You can follow the official documentation or:
Install with Rancher script
Install with Docker script
You only need to use one of the above commands.
Configure Docker
On all servers
, run the following command to start Docker.
Create a Swarm cluster
On the manager node
, run the following command to create a new cluster.
This command will output a command to join the cluster on the worker nodes
.
It should look like something like this:
Verify the cluster
Run the following command on the manager node to verify the cluster.
You should see something like this:
Deploy with persistent storage
To be able to deploy a service with persistent storage, you need to have a shared volume on the swarm-workers
. So the Swarm service could move the resources between the swarm-workers
.
You can always use services like AWS EFS, NFS, GlusterFS, etc.
WIP
Last updated