# gameadm Production Deployment Guide ## Single-Host Production mit Podman + systemd/Quadlet Dieser Guide beschreibt die Enterprise-taugliche Production-Deployment-Strategie für gameadm mit Podman, systemd/Quadlet und Woodpecker CI/CD. ## Architektur Übersicht ``` ┌─────────────────────────────────────────────────────┐ │ Production Host │ ├─────────────────────────────────────────────────────┤ │ 🔧 gameadm (rootless User) │ │ ├── systemd/Quadlet Integration │ │ ├── Podman Container Runtime │ │ ├── Auto-Update + Health Checks │ │ └── Zero-Downtime Deployments │ ├─────────────────────────────────────────────────────┤ │ 🎮 Game Servers (systemd Services) │ │ ├── minecraft.service (Port 25565) │ │ ├── rust.service (Port 28015/28016) │ │ └── Weitere Games (modular erweiterbar) │ ├─────────────────────────────────────────────────────┤ │ 📊 Monitoring & Backups │ │ ├── Health Checks alle 30s │ │ ├── Automatische Backups vor Updates │ │ ├── Rollback-Mechanismus │ │ └── systemd Integration │ └─────────────────────────────────────────────────────┘ ⬆ Woodpecker CI/CD (Zero-Downtime Deployments) ``` ## 1. Production Host Setup ### Automatisches Setup ```bash # Production Host Setup (als root) curl -fsSL https://git.pp1l.de/pp1l/gameadm/raw/branch/main/production/setup-production-host.sh | bash # Oder manuell: wget https://git.pp1l.de/pp1l/gameadm/raw/branch/main/production/setup-production-host.sh chmod +x setup-production-host.sh sudo ./setup-production-host.sh ``` ### Was das Setup macht: - ✅ **gameadm User erstellen** (rootless Betrieb) - ✅ **Podman installieren** und konfigurieren - ✅ **systemd/Quadlet** einrichten - ✅ **User Linger** aktivieren (persistente User-Services) - ✅ **Cgroups Delegation** konfigurieren - ✅ **SSH für CI/CD** vorbereiten - ✅ **Firewall** für Game-Ports konfigurieren - ✅ **Monitoring** und Health Checks einrichten ## 2. gameadm Installation ```bash # Als gameadm User sudo -u gameadm bash curl -fsSL https://git.pp1l.de/pp1l/gameadm/raw/branch/main/install.sh | bash # Game Server konfigurieren gameadm install minecraft gameadm install rust ``` ## 3. Production Deployment ### Rootless Quadlet Setup ```bash # Als gameadm User gameadm-quadlet setup rootless # Games als systemd Services deployen gameadm-quadlet deploy minecraft gameadm-quadlet deploy rust # Services aktivieren (Auto-Start beim Boot) gameadm-quadlet enable minecraft gameadm-quadlet enable rust # Services starten gameadm-quadlet start minecraft gameadm-quadlet start rust ``` ### Verfügbare Kommandos ```bash # Service Management gameadm-quadlet start minecraft gameadm-quadlet stop rust gameadm-quadlet restart minecraft gameadm-quadlet status rust gameadm-quadlet logs minecraft # Production Operations gameadm-quadlet update minecraft # Zero-Downtime Update gameadm-quadlet rollback rust # Rollback zur vorherigen Version gameadm-quadlet health minecraft # Health Check gameadm-quadlet backup rust # Backup erstellen ``` ## 4. Zero-Downtime Updates ### Automatischer Update-Prozess: 1. **Pre-Update Backup** (Config + Image Info) 2. **Health Check** vor Update 3. **Image Pull** (neues Container-Image) 4. **Graceful Restart** (podman auto-update) 5. **Post-Update Health Check** 6. **Cleanup** (alte Backups entfernen) ### Bei Update-Fehlern: - Automatischer **Rollback** verfügbar - **Backup-basierte Wiederherstellung** - **Health-Check-gesteuerter Prozess** ```bash # Update mit automatischem Rollback bei Fehlern gameadm-quadlet update minecraft # Manueller Rollback falls nötig gameadm-quadlet rollback minecraft ``` ## 5. Woodpecker CI/CD Integration ### Deployment Pipeline ```yaml # .woodpecker-deployment.yml Beispiel steps: deploy_minecraft: image: alpine:latest secrets: [ssh_private_key, production_host] commands: - ssh gameadm@$PRODUCTION_HOST - gameadm-quadlet update minecraft - gameadm-quadlet health minecraft ``` ### Deployment-Trigger: - ✅ **Git Push** auf main branch - ✅ **Manual Deployment** über Woodpecker UI - ✅ **Scheduled Deployments** (optional) - ✅ **Rollback bei Fehlern** ## 6. systemd/Quadlet Konfiguration ### Minecraft Container Definition ```ini # ~/.config/containers/systemd/minecraft.container [Unit] Description=Minecraft Server via gameadm After=network-online.target [Container] Image=docker.io/itzg/minecraft-server:latest AutoUpdate=registry PublishPort=25565:25565 Volume=/srv/minecraft:/data:Z Label=io.containers.autoupdate=registry [Service] Type=notify NotifyAccess=all Delegate=yes Restart=on-failure [Install] WantedBy=multi-user.target ``` ### Auto-Update Labels: - `io.containers.autoupdate=registry` - Aktiviert automatische Updates - `maintainer=gameadm` - Kennzeichnung für gameadm - `environment=production` - Production-Umgebung ## 7. Monitoring und Health Checks ### Health Check System: ```bash # Automatische Health Checks gameadm-quadlet health minecraft # ✓ oder ✗ gameadm-quadlet health rust # Port + Container Checks # System-weites Monitoring /usr/local/bin/gameadm-health-check # Vollständiger Report ``` ### Health Check Kriterien: - ✅ **Container Running** (podman inspect) - ✅ **Port Listening** (netstat check) - ✅ **Resource Usage** (Memory/CPU) - ✅ **Auto-Retry** (5 Versuche mit 5s Pause) ## 8. Backup und Disaster Recovery ### Automatische Backups: - **Pre-Update Backups** (vor jedem Update) - **Config Backups** (/etc/\*-server.conf) - **Image Info Backups** (für Rollbacks) - **Retention Policy** (5 neueste Backups) ### Rollback-Prozess: 1. **Service Stop** 2. **Config Restore** (aus Backup) 3. **Image Rollback** (Container neu erstellen) 4. **Service Start** 5. **Health Check** (Erfolg validieren) ## 9. Sicherheit ### Rootless Betrieb: - ✅ **User Namespaces** (Isolation) - ✅ **No Root Privileges** für Container - ✅ **SELinux/AppArmor** Integration - ✅ **Cgroups Limits** (Memory/CPU) ### Secrets Management: ```bash # Sichere Passwort-Speicherung /root/secrets/minecraft_rcon_password /root/secrets/rust_server_password chmod 600 /root/secrets/* # Quadlet Secret Integration Secret=minecraft_rcon_password,type=mount,target=/tmp/rcon_password ``` ## 10. Troubleshooting ### Häufige Probleme: **Container startet nicht:** ```bash gameadm-quadlet logs minecraft journalctl --user -u minecraft ``` **Port-Konflikte:** ```bash netstat -tlnp | grep 25565 gameadm-quadlet status minecraft ``` **Update-Fehler:** ```bash gameadm-quadlet rollback minecraft gameadm-quadlet health minecraft ``` **Service-Status prüfen:** ```bash systemctl --user status minecraft podman ps ``` ## 11. Erweiterungen ### Neue Games hinzufügen: 1. **Modul erstellen** (`/etc/gameadm/modules/newgame.sh`) 2. **cmd_install() implementieren** 3. **Quadlet-Template** erstellen 4. **Pipeline erweitern** ### Monitoring erweitern: - **Prometheus Metrics** (podman metrics) - **Grafana Dashboards** - **Alerting** (bei Service-Ausfällen) --- ## Zusammenfassung **gameadm Production Deployment** bietet: 🚀 **Enterprise-Grade Deployment** - Single-Host Production mit Podman + systemd - Rootless Container für maximale Sicherheit - Zero-Downtime Updates mit Rollback 🔧 **CI/CD Integration** - Woodpecker Pipeline für automatische Deployments - SSH-basierte Remote-Deployments - Health-Check-gesteuerte Updates 📊 **Monitoring & Reliability** - Automatische Health Checks - Backup-basierte Disaster Recovery - systemd Service Integration 🎮 **Game Server Ready** - Minecraft Server (Port 25565) - Rust Server (Port 28015/28016) - Modular erweiterbar für weitere Spiele Das System ist **production-ready** und bietet Enterprise-Standards für Game-Server-Hosting!