Build and Deploy to Synology NAS / test (push) Failing after 15m0s
Build and Deploy to Synology NAS / build (push) Has been cancelled
Build and Deploy to Synology NAS / deploy (push) Has been cancelled
Build and Deploy to Synology NAS / notify (push) Has been cancelled
- Add Terraform configuration for AKS cluster deployment - Add Kubernetes manifests for Laravel app (deployment, services, secrets) - Add PostgreSQL on Kubernetes with multi-schema support - Add Nginx Ingress Controller configuration - Add GitHub Actions workflow for Azure deployment - Add HTTP Basic Authentication for production - Add database restore functionality via Kubernetes jobs - Update Dockerfile and nginx config for production - Update database.php for multi-schema connections - Add deployment documentation and quickstart guides Deployed version: 1.0.7 at http://72.144.113.194/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
475 lines
9.6 KiB
Markdown
475 lines
9.6 KiB
Markdown
# ✅ Deployment Checklist
|
|
|
|
Diese Checkliste führt dich Schritt-für-Schritt durch das erste Deployment.
|
|
|
|
## 📋 Pre-Deployment
|
|
|
|
### 1. Lokale Umgebung
|
|
|
|
- [ ] Terraform >= 1.9.0 installiert
|
|
- [ ] Azure CLI >= 2.0 installiert
|
|
- [ ] kubectl >= 1.28 installiert
|
|
- [ ] Docker >= 20.10 installiert
|
|
- [ ] PHP >= 8.2 installiert (für Laravel-Befehle)
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
terraform version
|
|
az version
|
|
kubectl version
|
|
docker version
|
|
php -v
|
|
```
|
|
|
|
### 2. Azure Zugriff
|
|
|
|
- [ ] Azure Account vorhanden
|
|
- [ ] Subscription ID bekannt: `77677a80-2dea-493d-9867-f1c961b80fb3`
|
|
- [ ] Zugriff auf Resource Group: `trusted_ai_demo_rg`
|
|
- [ ] Zugriff auf AKS Cluster: `trai_k8s_cluster`
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
az login
|
|
az account set --subscription "77677a80-2dea-493d-9867-f1c961b80fb3"
|
|
az account show
|
|
az aks show --resource-group trusted_ai_demo_rg --name trai_k8s_cluster
|
|
```
|
|
|
|
## 🔧 Setup
|
|
|
|
### 3. Azure Container Registry
|
|
|
|
- [ ] ACR erstellt oder vorhanden
|
|
- [ ] ACR Name: `mylaravelregistry` (oder eigener Name)
|
|
- [ ] AKS hat Pull-Berechtigung für ACR
|
|
|
|
**Erstellen:**
|
|
```bash
|
|
# ACR erstellen (falls noch nicht vorhanden)
|
|
az acr create \
|
|
--resource-group trusted_ai_demo_rg \
|
|
--name mylaravelregistry \
|
|
--sku Basic \
|
|
--location germanywestcentral
|
|
|
|
# AKS Zugriff geben
|
|
az aks update \
|
|
--resource-group trusted_ai_demo_rg \
|
|
--name trai_k8s_cluster \
|
|
--attach-acr mylaravelregistry
|
|
|
|
# Login
|
|
az acr login --name mylaravelregistry
|
|
```
|
|
|
|
### 4. Docker Image
|
|
|
|
- [ ] Docker Image gebaut
|
|
- [ ] Docker Image zu ACR gepusht
|
|
- [ ] Image Tag notiert
|
|
|
|
**Bauen & Pushen:**
|
|
```bash
|
|
cd /Users/sebastianfrohlich/Herd/frontend
|
|
|
|
# Bauen
|
|
docker build -t mylaravelregistry.azurecr.io/laravel-app:v1.0.0 .
|
|
|
|
# Pushen
|
|
docker push mylaravelregistry.azurecr.io/laravel-app:v1.0.0
|
|
|
|
# Image Tag notieren:
|
|
IMAGE_TAG="mylaravelregistry.azurecr.io/laravel-app:v1.0.0"
|
|
```
|
|
|
|
### 5. Laravel Konfiguration
|
|
|
|
- [ ] APP_KEY generiert
|
|
- [ ] APP_KEY notiert
|
|
|
|
**Generieren:**
|
|
```bash
|
|
cd /Users/sebastianfrohlich/Herd/frontend
|
|
php artisan key:generate --show
|
|
|
|
# Output: base64:xyz...
|
|
# Notieren für terraform.tfvars
|
|
```
|
|
|
|
### 6. Backup-Dateien
|
|
|
|
- [ ] Database Backup vorhanden
|
|
- [ ] Backup-Pfad notiert
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
ls -lh /Users/sebastianfrohlich/Herd/frontend/backups/
|
|
|
|
# Wähle ein Backup, z.B.:
|
|
BACKUP_FILE="../backups/backup_backend_20251203_101741.dump"
|
|
```
|
|
|
|
## ⚙️ Terraform Konfiguration
|
|
|
|
### 7. terraform.tfvars erstellen
|
|
|
|
- [ ] `terraform.tfvars` aus Example kopiert
|
|
- [ ] Alle erforderlichen Werte eingetragen
|
|
|
|
**Erstellen:**
|
|
```bash
|
|
cd /Users/sebastianfrohlich/Herd/frontend/terraform
|
|
cp terraform.tfvars.example terraform.tfvars
|
|
nano terraform.tfvars
|
|
```
|
|
|
|
**Erforderliche Werte:**
|
|
|
|
```hcl
|
|
# ✅ Docker Image
|
|
docker_image = "mylaravelregistry.azurecr.io/laravel-app:v1.0.0"
|
|
|
|
# ✅ Laravel APP_KEY
|
|
app_key = "base64:YOUR_GENERATED_KEY_HERE"
|
|
|
|
# ✅ PostgreSQL Admin Password (sicher wählen!)
|
|
postgresql_admin_password = "YourVerySecurePassword123!"
|
|
|
|
# ✅ Alert Email
|
|
alert_email_address = "your-email@example.com"
|
|
|
|
# ✅ Database Restore (beim ersten Deployment)
|
|
db_restore_enabled = true
|
|
db_backup_file_path = "../backups/backup_backend_20251203_101741.dump"
|
|
```
|
|
|
|
**Optionale Werte:**
|
|
|
|
```hcl
|
|
# Für Custom Domain
|
|
ingress_host = "app.yourdomain.com"
|
|
|
|
# Für SSL/TLS (benötigt Domain)
|
|
ssl_enabled = true
|
|
ssl_issuer_email = "admin@yourdomain.com"
|
|
|
|
# Ressourcen anpassen
|
|
app_replicas = 2
|
|
postgresql_sku_name = "B_Standard_B1ms"
|
|
```
|
|
|
|
### 8. Konfiguration validieren
|
|
|
|
- [ ] terraform.tfvars Syntax korrekt
|
|
- [ ] Alle Secrets/Passwörter sicher
|
|
- [ ] Backup-Pfad korrekt
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
cd terraform
|
|
|
|
# Terraform init
|
|
terraform init
|
|
|
|
# Validate
|
|
terraform validate
|
|
|
|
# Sollte ausgeben: Success! The configuration is valid.
|
|
```
|
|
|
|
## 🚀 Deployment
|
|
|
|
### 9. Deployment ausführen
|
|
|
|
**Option A: Automatisches Script (Empfohlen)**
|
|
|
|
- [ ] Deploy-Script ausgeführt
|
|
|
|
```bash
|
|
cd /Users/sebastianfrohlich/Herd/frontend/terraform
|
|
./scripts/deploy.sh
|
|
```
|
|
|
|
Das Script führt automatisch aus:
|
|
1. ✅ Prerequisite Check
|
|
2. ✅ Azure Login Status
|
|
3. ✅ terraform.tfvars Check
|
|
4. ✅ Docker Image Check
|
|
5. ✅ APP_KEY Check
|
|
6. ✅ terraform init
|
|
7. ✅ terraform validate
|
|
8. ✅ terraform plan
|
|
9. ✅ terraform apply (nach Bestätigung)
|
|
10. ✅ kubectl konfigurieren
|
|
11. ✅ Pod Status prüfen
|
|
|
|
**Option B: Manuell**
|
|
|
|
- [ ] Terraform Plan erstellt
|
|
- [ ] Plan überprüft
|
|
- [ ] Terraform Apply ausgeführt
|
|
|
|
```bash
|
|
cd terraform
|
|
|
|
# Plan
|
|
terraform plan -out=tfplan
|
|
|
|
# Plan überprüfen
|
|
# Sollte Resources anzeigen: +XX to add, ~0 to change, -0 to destroy
|
|
|
|
# Apply
|
|
terraform apply tfplan
|
|
|
|
# Outputs anzeigen
|
|
terraform output
|
|
terraform output deployment_instructions
|
|
```
|
|
|
|
### 10. kubectl konfigurieren
|
|
|
|
- [ ] kubectl Credentials abgerufen
|
|
- [ ] Cluster-Zugriff getestet
|
|
|
|
```bash
|
|
az aks get-credentials \
|
|
--resource-group trusted_ai_demo_rg \
|
|
--name trai_k8s_cluster \
|
|
--overwrite-existing
|
|
|
|
# Testen
|
|
kubectl get nodes
|
|
kubectl get namespaces
|
|
```
|
|
|
|
## 🔄 Database Restore
|
|
|
|
### 11. Datenbank wiederherstellen
|
|
|
|
**Option A: Automatisches Script (Empfohlen)**
|
|
|
|
- [ ] Restore-Script ausgeführt
|
|
- [ ] Job Status geprüft
|
|
|
|
```bash
|
|
cd /Users/sebastianfrohlich/Herd/frontend/terraform
|
|
./scripts/restore-db.sh
|
|
|
|
# Script fragt nach:
|
|
# - Welches Backup-File?
|
|
# - Bestätigung: yes
|
|
# Zeigt dann Logs und Status
|
|
```
|
|
|
|
**Option B: Via Terraform**
|
|
|
|
- [ ] `db_restore_enabled = true` in terraform.tfvars
|
|
- [ ] `terraform apply` ausgeführt
|
|
|
|
```bash
|
|
# In terraform.tfvars:
|
|
db_restore_enabled = true
|
|
db_backup_file_path = "../backups/backup_backend_20251203_101741.dump"
|
|
|
|
# Apply
|
|
terraform apply
|
|
|
|
# Job Status prüfen
|
|
kubectl get jobs -n laravel-app
|
|
kubectl logs -n laravel-app -l job-type=database-restore -f
|
|
```
|
|
|
|
## ✅ Post-Deployment Checks
|
|
|
|
### 12. Infrastruktur Status
|
|
|
|
- [ ] Pods sind running
|
|
- [ ] Service ist erreichbar
|
|
- [ ] Ingress hat External IP
|
|
- [ ] Database ist connected
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Pods
|
|
kubectl get pods -n laravel-app
|
|
# Sollte: 2/2 Running anzeigen
|
|
|
|
# Service
|
|
kubectl get svc -n laravel-app
|
|
|
|
# Ingress
|
|
kubectl get svc ingress-nginx-controller -n ingress-nginx
|
|
# Sollte: EXTERNAL-IP anzeigen (dauert 5-10 Min)
|
|
|
|
# Database
|
|
kubectl get secret laravel-app-db-credentials -n laravel-app
|
|
```
|
|
|
|
### 13. Application Health
|
|
|
|
- [ ] Application ist erreichbar
|
|
- [ ] HTTP Status 200 oder 302
|
|
- [ ] Keine Fehler in Logs
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# URL abrufen
|
|
terraform output app_url
|
|
|
|
# Beispiel Output: http://20.79.123.456
|
|
|
|
# Im Browser öffnen oder:
|
|
curl -I http://20.79.123.456
|
|
|
|
# Sollte: HTTP/1.1 200 OK oder 302 Found
|
|
|
|
# Logs prüfen
|
|
kubectl logs -n laravel-app -l app=laravel-app -f
|
|
|
|
# Sollte: Keine Errors zeigen
|
|
```
|
|
|
|
### 14. Database Connectivity
|
|
|
|
- [ ] Database Restore Job completed
|
|
- [ ] Laravel kann auf DB zugreifen
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Restore Job Status
|
|
kubectl get jobs -n laravel-app
|
|
# Sollte: db-restore-* mit COMPLETIONS 1/1
|
|
|
|
# Job Logs
|
|
kubectl logs -n laravel-app -l job-type=database-restore
|
|
|
|
# Sollte: "Database restore completed successfully!" enthalten
|
|
|
|
# Laravel Migrations Status (in Pod)
|
|
POD_NAME=$(kubectl get pods -n laravel-app -l app=laravel-app -o jsonpath='{.items[0].metadata.name}')
|
|
kubectl exec -it -n laravel-app $POD_NAME -- php artisan migrate:status
|
|
|
|
# Sollte: Migration table anzeigen
|
|
```
|
|
|
|
## 🎯 Finalisierung
|
|
|
|
### 15. Monitoring Setup
|
|
|
|
- [ ] Azure Monitor funktioniert
|
|
- [ ] Alert Rules aktiv
|
|
- [ ] Email Alerts konfiguriert
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Azure Portal öffnen
|
|
open https://portal.azure.com
|
|
|
|
# Gehe zu:
|
|
# 1. Resource Group: trusted_ai_demo_rg
|
|
# 2. AKS Cluster: trai_k8s_cluster
|
|
# 3. Monitoring > Insights
|
|
|
|
# Alert Rules prüfen:
|
|
az monitor metrics alert list \
|
|
--resource-group trusted_ai_demo_rg
|
|
```
|
|
|
|
### 16. Dokumentation
|
|
|
|
- [ ] LoadBalancer IP notiert
|
|
- [ ] Database Connection String notiert
|
|
- [ ] Terraform Outputs gespeichert
|
|
|
|
**Notieren:**
|
|
```bash
|
|
# Alle Outputs anzeigen
|
|
terraform output
|
|
|
|
# Spezifische Outputs
|
|
terraform output app_url
|
|
terraform output postgresql_server_fqdn
|
|
terraform output postgresql_connection_string
|
|
|
|
# In Passwort-Manager oder sicheren Ort speichern!
|
|
```
|
|
|
|
### 17. Cleanup & Security
|
|
|
|
- [ ] Sensitive Dateien nicht committed (terraform.tfvars)
|
|
- [ ] Passwörter sicher gespeichert
|
|
- [ ] .gitignore überprüft
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Git Status
|
|
git status
|
|
|
|
# Sollte NICHT enthalten:
|
|
# - terraform.tfvars
|
|
# - *.tfstate
|
|
# - kubeconfig
|
|
|
|
# Falls vorhanden:
|
|
git rm --cached terraform/terraform.tfvars
|
|
git rm --cached terraform/*.tfstate
|
|
```
|
|
|
|
## 🚦 Success Criteria
|
|
|
|
Deployment ist erfolgreich wenn:
|
|
|
|
- ✅ `kubectl get pods -n laravel-app` zeigt 2/2 Running
|
|
- ✅ `terraform output app_url` zeigt eine URL
|
|
- ✅ URL im Browser ist erreichbar
|
|
- ✅ Database Restore Job ist completed
|
|
- ✅ Keine Fehler in Pod Logs
|
|
- ✅ Ingress hat External IP
|
|
|
|
## 🎉 Fertig!
|
|
|
|
Deine Laravel-Anwendung läuft jetzt auf Azure Kubernetes Service!
|
|
|
|
### Nächste Schritte:
|
|
|
|
1. **Testen**: Funktionalität der Anwendung testen
|
|
2. **Monitoring**: Azure Monitor regelmäßig prüfen
|
|
3. **Backups**: PostgreSQL Backup-Strategy überprüfen
|
|
4. **Domain**: Custom Domain konfigurieren (optional)
|
|
5. **SSL**: Let's Encrypt aktivieren (optional)
|
|
6. **CI/CD**: GitHub Actions einrichten (optional)
|
|
|
|
### Wichtige Commands:
|
|
|
|
```bash
|
|
# Status prüfen
|
|
kubectl get all -n laravel-app
|
|
|
|
# Logs anzeigen
|
|
kubectl logs -n laravel-app -l app=laravel-app -f
|
|
|
|
# Shell in Pod
|
|
kubectl exec -it -n laravel-app <pod-name> -- /bin/sh
|
|
|
|
# Port-forward für lokalen Zugriff
|
|
kubectl port-forward -n laravel-app svc/laravel-app 8080:80
|
|
|
|
# Terraform Outputs
|
|
terraform output deployment_instructions
|
|
```
|
|
|
|
## 📞 Support
|
|
|
|
Bei Problemen:
|
|
|
|
1. **Troubleshooting Guide**: [README.md#troubleshooting](README.md#troubleshooting)
|
|
2. **Kubernetes Events**: `kubectl get events -n laravel-app --sort-by='.lastTimestamp'`
|
|
3. **Pod Logs**: `kubectl logs -n laravel-app <pod-name>`
|
|
4. **Terraform State**: `terraform show`
|
|
|
|
---
|
|
|
|
**Deployment Time**: ~30 Minuten
|
|
**Status**: ✅ Ready for Production
|