Add swarm config

This commit is contained in:
lif
2025-10-10 19:36:51 +01:00
parent 520fef57a1
commit 069ac709e1
9 changed files with 594 additions and 285 deletions

View File

@@ -1,42 +1,48 @@
# Bare Bones Vagrant Setup
# Docker Swarm Vagrant Cluster
A **ultra-lightweight** Vagrant setup with 4 machines and a host for basic testing and development.
A **production-ready** Docker Swarm cluster with 1 manager and 3 worker nodes for container orchestration and deployment.
## ⚡ Ultra-Lightweight Features
## 🐳 Docker Swarm Features
- **512MB RAM per machine** - Minimal memory footprint
- **Debian Linux base** - ~150MB base image, ~400MB with tools
- **No provisioning scripts** - Pure Debian base
- **No shared folders** - Disabled for performance
- **Minimal network** - Just basic connectivity
- **Fast startup** - Debian boots quickly
- **1 Swarm Manager** - Cluster orchestration and management
- **3 Swarm Workers** - Container execution and scaling
- **Overlay Networking** - Secure multi-host container communication
- **Service Discovery** - Built-in DNS and load balancing
- **High Availability** - Automatic failover and service recovery
- **Portainer UI** - Web-based cluster management interface
- **Traefik** - Reverse proxy with automatic service discovery
## 🏗️ Architecture
```
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
host │ │ machine1 │ │ machine2 │ │ machine3 │
│ 192.168.56.1│ │192.168.56.10│ │192.168.56.11│ │192.168.56.12
│ │ │ │ │ │ │ │
│ - Host │ │ - Machine 1 │ │ - Machine 2 │ │ - Machine 3
│ - Gateway │ │ - Debian │ │ - Debian │ │ - Debian
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
┌─────────────┐
│ machine4 │
192.168.56.13
│ │
│ - Machine 4
│ - Debian │
└─────────────┘
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────
swarm-manager │ │ swarm-worker1 │ │ swarm-worker2 │ │ swarm-worker3 │
│ 192.168.56.10 │ │ 192.168.56.11 │ │ 192.168.56.12 │ │ 192.168.56.13
│ │ │ │ │ │
│ - Swarm Manager │ │ - Swarm Worker │ │ - Swarm Worker │ │ - Swarm Worker
│ - Portainer UI │ │ - Container │ │ - Container │ │ - Container
│ - Traefik Proxy │ │ Execution │ │ Execution │ │ Execution │
│ - Service │ - Load │ - Load │ - Load
Discovery Balancing Balancing Balancing │
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘
└───────────────────────┼───────────────────────┼───────────────────────┘
┌─────────────┴───────────────────────┴─────────────┐
Docker Swarm Overlay Network │
│ - Service Discovery │
│ - Load Balancing │
│ - Secure Communication │
└─────────────────────────────────────────────────────┘
```
## 📋 Prerequisites
- **Vagrant** 2.2+
- **VirtualBox** 6.0+ or **libvirt** (KVM)
- **3GB+ RAM** (512MB per machine)
- **4GB+ free disk space**
- **Ansible** 2.9+
- **2GB+ RAM** (512MB per machine + 1GB swap)
- **6GB+ free disk space**
## 🚀 Quick Start
@@ -52,8 +58,8 @@ A **ultra-lightweight** Vagrant setup with 4 machines and a host for basic testi
3. **Access a machine:**
```bash
make ssh-host
make ssh-machine1
make ssh-manager
make ssh-worker1
```
## 🎛️ Management Commands
@@ -64,11 +70,10 @@ make start # Start all machines
make stop # Stop all machines
make destroy # Destroy all machines
make status # Show machine status
make ssh-host # Access host machine
make ssh-machine1 # Access machine1
make ssh-machine2 # Access machine2
make ssh-machine3 # Access machine3
make ssh-machine4 # Access machine4
make ssh-manager # Access swarm manager
make ssh-worker1 # Access swarm worker1
make ssh-worker2 # Access swarm worker2
make ssh-worker3 # Access swarm worker3
```
### Using Management Script
@@ -77,8 +82,8 @@ make ssh-machine4 # Access machine4
./manage.sh stop # Stop all machines
./manage.sh destroy # Destroy all machines
./manage.sh status # Show machine status
./manage.sh ssh host # Access host machine
./manage.sh ssh machine1 # Access machine1
./manage.sh ssh swarm-manager # Access swarm manager
./manage.sh ssh swarm-worker1 # Access swarm worker1
```
### Using Vagrant Directly
@@ -87,19 +92,18 @@ vagrant up # Start all machines
vagrant halt # Stop all machines
vagrant destroy -f # Destroy all machines
vagrant status # Show machine status
vagrant ssh host # Access host machine
vagrant ssh machine1 # Access machine1
vagrant ssh swarm-manager # Access swarm manager
vagrant ssh swarm-worker1 # Access swarm worker1
```
## 🌐 Network Configuration
- **Host**: 192.168.56.1
- **Machine 1**: 192.168.56.10
- **Machine 2**: 192.168.56.11
- **Machine 3**: 192.168.56.12
- **Machine 4**: 192.168.56.13
- **Swarm Manager**: 192.168.56.10
- **Swarm Worker 1**: 192.168.56.11
- **Swarm Worker 2**: 192.168.56.12
- **Swarm Worker 3**: 192.168.56.13
All machines are connected via a private network and can communicate with each other.
All machines are connected via a private network and communicate through Docker Swarm overlay networking.
## 🔧 Machine Specifications