Uptime Kuma is a self-hosted monitoring tool that allows you to keep track of your websites, services, or APIs with ease. In this guide, we'll go through the process of deploying Uptime Kuma on a Docker Swarm cluster using a highly available configuration. This setup uses an NFS share to ensure persistent data storage across nodes.
Prerequisites
- Docker Swarm Cluster: A working Docker Swarm cluster with at least one manager and one worker node.
- NFS Server: A configured NFS server to store the persistent data.
- Basic Docker Knowledge: Familiarity with Docker Compose and Swarm concepts.
Docker Compose Configuration
Here is the sanitized Docker Compose configuration we used for this deployment:
services:
uptime-kuma:
image: louislam/uptime-kuma:1
ports:
- "3002:3001"
environment:
- DB_TYPE=sqlite
- DB_STORAGE=/app/data/uptime-kuma.db
- SOFTWARE_VERSION_TAG=latest
volumes:
- nfs-kuma:/app/data
restart: always
deploy:
placement:
constraints:
- node.role == worker
volumes:
nfs-kuma:
driver: local
driver_opts:
device: :/path/to/your/nfs/share
o: addr=your.nfs.server.ip,nolock,soft,rw,nfsvers=4
type: nfs
Explanation of Key Sections
- Service Configuration:
- The
uptime-kuma
service uses the official image from Docker Hub. - Port
3001
inside the container is mapped to port3002
on the host. - Persistent data is stored using SQLite on an NFS volume.
- The
- Environment Variables:
DB_TYPE
: Specifies SQLite as the database type.DB_STORAGE
: Path to the database file within the container.SOFTWARE_VERSION_TAG
: Ensures the latest version is used.
- Placement Constraints:
- Ensures the service is deployed on a worker node.
- Volume Configuration:
- The volume
nfs-kuma
uses thelocal
driver withNFS
options pointing to the NFS server.
- The volume
Deployment Steps
1. Initialize the Swarm
If you haven't already initialized a Docker Swarm, run:
docker swarm init
For multi-node setup, join additional nodes using the command provided after initializing the swarm.
2. Create the Stack File
Save the above sanitized Docker Compose configuration as docker-compose.yml
.
3. Deploy the Stack
Deploy the stack with:
docker stack deploy -c docker-compose.yml uptime-kuma-stack
4. Verify Deployment
Check the status of the service:
docker service ls
Access Uptime Kuma in your browser at http://<manager-or-worker-ip>:3002
.
Monitoring and Scaling
Scaling: You can scale the service if needed:
docker service scale uptime-kuma-stack_uptime-kuma=2
Logs: View logs for troubleshooting:
docker service logs uptime-kuma-stack_uptime-kuma
Benefits of this Setup
- High Availability: Deploying on Swarm ensures fault tolerance by distributing the service across worker nodes.
- Persistent Data: Using an NFS share ensures data is retained even if a container is recreated or moved.
- Ease of Use: Docker Swarm simplifies orchestration and scaling compared to standalone Docker deployments.
you can check a dashboard I made publicly available
This setup offers a robust and scalable deployment of Uptime Kuma with persistent data storage and high availability. By leveraging Docker Swarm and NFS, you ensure reliability and flexibility in your monitoring solution. Try it out, and enjoy seamless service monitoring!