florale-emotion/DEPLOYMENT.md

4.2 KiB

Florale Emotion - Kubernetes Deployment

Dieses Dokument beschreibt das Deployment-Setup für das Florale Emotion Projekt.

Übersicht

Das Projekt besteht aus drei Hauptkomponenten:

  • Frontend: Angular-basierte Website
  • Backend: Node.js API Server
  • Social Media Bot: Automatisierte Social Media Posting

Deployment-Umgebungen

Development

Production

Pipeline-Struktur

Gitea Workflow

Die Pipeline wird durch .gitea/workflows/deploy.yml definiert und umfasst:

  1. Feature Branch Deployment

    • Baut und pushed Docker Images mit Branch-spezifischen Tags
    • Deployed auf dev.florale-emotion.de
    • Verwendet dynamische Image-Tags (kein latest)
  2. Production Deployment

    • Baut und pushed sowohl versionierte als auch latest Tags
    • Deployed auf florale-emotion.de
    • Vollständige SSL-Konfiguration

Docker Images

Alle Images werden in der Harbor Registry gespeichert:

  • registry.julianvollmer.de/florale-emotion/florale-emotion-frontend
  • registry.julianvollmer.de/florale-emotion/florale-emotion-backend
  • registry.julianvollmer.de/florale-emotion/florale-emotion-bot

Kubernetes-Manifeste

Frontend (website/k8s/frontend.yaml)

  • 2 Replicas für High Availability
  • Nginx-basiertes Angular Deployment
  • Health Checks auf Port 80
  • Resource Limits: 256Mi RAM, 200m CPU

Backend (website/k8s/backend.yaml)

  • 2 Replicas für Load Balancing
  • Node.js API auf Port 3000
  • Health Checks auf /health Endpoint
  • Resource Limits: 512Mi RAM, 300m CPU

Social Media Bot (website/k8s/bot.yaml)

  • 1 Replica (Singleton Service)
  • Scheduled/Cron-basierte Ausführung
  • Resource Limits: 256Mi RAM, 100m CPU

Ingress Konfiguration

  • Production (ingress.yaml): florale-emotion.de, www.florale-emotion.de, api.florale-emotion.de
  • Development (ingress-dev.yaml): dev.florale-emotion.de, api-dev.florale-emotion.de
  • Automatische SSL-Zertifikate via Let's Encrypt
  • HTTPS-Weiterleitung aktiviert

Deployment-Prozess

Automatisches Deployment

  1. Code-Push auf Feature-Branch oder Main
  2. Gitea Pipeline startet automatisch
  3. Docker Images werden gebaut und gepushed
  4. Kubernetes Deployments werden aktualisiert
  5. Health Checks bestätigen erfolgreiche Bereitstellung

Manuelle Schritte (falls nötig)

# Namespace erstellen
kubectl create namespace florale-emotion

# Harbor Registry Secret erstellen
kubectl create secret docker-registry harbor-registry-secret \
  --docker-server=registry.julianvollmer.de \
  --docker-username=admin \
  --docker-password=Harbor12345 \
  --namespace=florale-emotion

# Deployments anwenden
kubectl apply -f website/k8s/ -n florale-emotion

Monitoring & Troubleshooting

Logs anzeigen

# Frontend Logs
kubectl logs -f deployment/florale-emotion-frontend -n florale-emotion

# Backend Logs
kubectl logs -f deployment/florale-emotion-backend -n florale-emotion

# Bot Logs
kubectl logs -f deployment/florale-emotion-bot -n florale-emotion

Status prüfen

# Deployment Status
kubectl get deployments -n florale-emotion

# Pod Status
kubectl get pods -n florale-emotion

# Service Status
kubectl get services -n florale-emotion

# Ingress Status
kubectl get ingress -n florale-emotion

Sicherheit

  • Alle Images werden aus einer privaten Harbor Registry bezogen
  • Non-root Container für Backend und Bot
  • Security Headers in Nginx-Konfiguration
  • HTTPS-Erzwingung für alle Domains
  • Resource Limits für alle Container

Skalierung

Die Anwendung kann horizontal skaliert werden:

# Frontend skalieren
kubectl scale deployment florale-emotion-frontend --replicas=3 -n florale-emotion

# Backend skalieren
kubectl scale deployment florale-emotion-backend --replicas=3 -n florale-emotion

Backup & Recovery

  • Kubernetes-Manifeste sind in Git versioniert
  • Docker Images sind in Harbor Registry gespeichert
  • Datenbank-Backups (falls vorhanden) sollten separat konfiguriert werden