Files
minecraft/README.md
2026-02-14 17:48:37 +01:00

172 lines
3.8 KiB
Markdown

# Minecraft Server - Biohazard Project Genesis
Questo progetto contiene i manifest Kubernetes per distribuire un server Minecraft con il modpack **Biohazard Project Genesis** (Fallout-themed).
## Files
- `namespace.yaml` - Crea il namespace `minecraft`
- `pvc.yaml` - PersistentVolumeClaim per i dati del mondo (50GB)
- `init-configmap.yaml` - ConfigMap per gli script di inizializzazione
- `configmap.yaml` - Configurazione del server (server.properties)
- `statefulset.yaml` - Deployment del server Minecraft
- `service.yaml` - Servizio LoadBalancer per l'accesso esterno
- `Dockerfile` - Immagine personalizzata con modpack installato
- `server-start.sh` - Script di avvio del server
- `values.yaml` - File values per Helm (opzionale)
- `deploy.sh` - Script di deployment automatico
## Prerequisiti
- Kubernetes cluster con Longhorn storage (storageClassName: `longhorn-fast`)
- Docker per buildare l'immagine personalizzata
- kubectl configurato per accedere al cluster
## Configurazione
### Modpack Details
- **Modpack ID**: 1082278
- **Nome**: Biohazard Project Genesis
- **Minecraft Version**: 1.20.1
- **Modloader**: Forge
- **File ID**: da autenticare via API CurseForge
### Resource Requirements
- **CPU**: 2 core (4 max)
- **Memory**: 8GB (4GB min, 8GB max)
- **Storage**: 50GB (longhorn-fast)
- **Players**: fino a 50
## Deployment
### Metodo 1: Manualmente
```bash
# Create namespace
kubectl apply -f namespace.yaml
# Create PVC
kubectl apply -f pvc.yaml
# Apply ConfigMaps
kubectl apply -f init-configmap.yaml
kubectl apply -f configmap.yaml
# Build Docker image
docker build -t your-registry/minecraft-biohazard:latest .
# Update image tag in statefulset.yaml
# Deploy
kubectl apply -f statefulset.yaml
kubectl apply -f service.yaml
```
### Metodo 2: Con script
```bash
chmod +x deploy.sh
./deploy.sh
```
## Monitoraggio
```bash
# Check pod status
kubectl get pods -n minecraft
kubectl logs -n minecraft -f <pod-name>
# Port-forward per accesso locale
kubectl port-forward -n minecraft svc/minecraft-service 25565:25565
# Check logs
kubectl logs -n minecraft statefulset/minecraft-server -f
```
## Accesso
Dopo il deployment, ottenere l'IP del LoadBalancer:
```bash
kubectl get svc -n minecraft minecraft-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}'
```
Connessione in-game: `IP:25565`
## Configurazione
### Modificare server.properties
Modificare il ConfigMap `minecraft-config`:
```bash
kubectl edit configmap minecraft-config -n minecraft
```
Poi restartare il pod:
```bash
kubectl rollout restart statefulset minecraft-server -n minecraft
```
### Aggiungere mods manualmente
1. Copiare i mods in `/data/mods/` dentro il PVC
2. Restartare il server
## Backup
Il PVC `minecraft-data` contiene tutto il world data. Per backup:
```bash
# Create snapshot
kubectl apply -f trivy-pvc.yaml # usa trivy-pvc.yaml come template
# O montare il PVC in un pod di backup
```
## Troubleshooting
### Pod in CrashLoopBackOff
```bash
kubectl logs -n minecraft <pod-name> -f
kubectl describe pod -n minecraft <pod-name>
```
### Modpack non installato
Controllare gli script in `/docker-entrypoint-initd/`:
```bash
kubectl exec -n minecraft <pod-name> -- ls -la /docker-entrypoint-initd/
```
### Modificare resource limits
Modificare lo StatefulSet:
```bash
kubectl edit statefulset minecraft-server -n minecraft
```
## Struttura del PVC
Dopo il primo avvio, il PVC conterrà:
```
/data/
├── server.jar
├── mods/
├── configs/
├── saves/
├── logs/
└── server.properties
```
## Note
- Il server scarica il modpack da CurseForge durante il primo avvio
- È consigliato impostare `online-mode=false` per evitare problemi di autenticazione
- Per produzione, considerare l'uso di un registro Docker privato
- Il backup del PVC è fondamentale per preservare il world data