refactor(k8s): Aufbau wie Wabenhain/ApiCore, Zertifikat funktionsfaehig
Docker-Images bauen und veroeffentlichen / build-and-push (push) Successful in 3m2s

- Dateinamen nach Wabenhain-Schema (01-configmap, 02-secret,
  03-storage, 04-postgres, 05-app-deployment, 06-ingress,
  07-worker-cronjob, 08-networkpolicy); Secret-Vorlage als
  02-secret.yaml.example, echte 02-secret.yaml gitignored.
- Namespace: Pod Security "baseline" erzwungen, "restricted" als warn/audit.
  "restricted" kann den HTTP-01-Solver-Pod von cert-manager abweisen und
  damit die Zertifikatsausstellung blockieren.
- NetworkPolicy nur noch fuer PostgreSQL; keine Policy vor der App (wie
  Wabenhain/ApiCore), da sie bei Traefik im Host-Netzwerk die Seite sperrt.
- README: kompletter Neuaufbau inkl. Freigabe der Retain-PVs nach
  "kubectl delete namespace", Zertifikats-Diagnose.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Opus 5.5 committed 2026-09-28 11:26:13 +02:00
1 parent d813d56514
commit a0ba921d19
12 files changed
+70 -71

No files matched your search

+33 -17
View File
@@ -10,7 +10,7 @@ Prüfen:
```bash
kubectl get ingressclass
kubectl get clusterissuer letsencrypt-prod
kubectl get pods -A -l 'app.kubernetes.io/name in (traefik,rke2-traefik)'
kubectl get csidrivers | grep smb
```
## Einmalige Vorbereitung
@@ -21,26 +21,40 @@ kubectl get pods -A -l 'app.kubernetes.io/name in (traefik,rke2-traefik)'
helm repo add csi-driver-smb https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/charts
helm install csi-driver-smb csi-driver-smb/csi-driver-smb -n kube-system
```
3. **NAS:** Die Ordner `artista/modelcamp-postgres` (leer) und `artista/modelcamp-media` anlegen und SMB-Verschlüsselung erlauben. `nas.example.lan` in `02-storage.yaml` anpassen.
4. **Domain:** `modelcamp.example.org` in `01-config.yaml` (APP_URL) und `05-ingress.yaml` (2×) ersetzen. Der DNS-Eintrag muss auf den Cluster zeigen, sonst stellt cert-manager kein Zertifikat aus.
5. **Secrets:** `cp k8s/secrets.yaml.example k8s/secrets.yaml` und ausfüllen. Die Datei steht in `.gitignore`, bitte **nie** mit echten Werten committen.
3. **NAS:** Die Ordner `artista/modelcamp-postgres` (leer) und `artista/modelcamp-media` anlegen und SMB-Verschlüsselung erlauben. `nas.example.lan` in `03-storage.yaml` anpassen.
4. **Domain:** `modelcamp.example.org` in `01-configmap.yaml` (APP_URL) und `06-ingress.yaml` (2×) ersetzen. Der DNS-Eintrag muss auf den Cluster zeigen, sonst stellt cert-manager kein Zertifikat aus.
5. **Secrets:** `cp k8s/02-secret.yaml.example k8s/02-secret.yaml` und ausfüllen. Die Datei steht in `.gitignore`, bitte **nie** mit echten Werten committen.
## Deployment
## Deployment (auch für einen kompletten Neuaufbau)
```bash
kubectl apply -f k8s/00-namespace.yaml
kubectl apply -f k8s/secrets.yaml
kubectl apply -f k8s/01-config.yaml
kubectl apply -f k8s/02-storage.yaml
kubectl apply -f k8s/03-postgres.yaml
kubectl apply -f k8s/01-configmap.yaml
kubectl apply -f k8s/02-secret.yaml
kubectl apply -f k8s/03-storage.yaml
kubectl apply -f k8s/04-postgres.yaml
kubectl wait --for=condition=ready pod -l app=artista-modelcamp-postgres -n artista --timeout=180s
kubectl apply -f k8s/04-app.yaml
kubectl apply -f k8s/05-ingress.yaml
kubectl apply -f k8s/06-worker.yaml
kubectl apply -f k8s/07-networkpolicy.yaml
kubectl apply -f k8s/05-app-deployment.yaml
kubectl apply -f k8s/06-ingress.yaml
kubectl apply -f k8s/07-worker-cronjob.yaml
kubectl apply -f k8s/08-networkpolicy.yaml
```
Die Migration läuft automatisch als initContainer vor dem App-Start. Den Fortschritt zeigt `kubectl rollout status deployment/artista-modelcamp-app -n artista`, das Zertifikat `kubectl get certificate -n artista`.
Die Migration läuft automatisch als initContainer vor dem App-Start. Den Stand zeigen:
```bash
kubectl rollout status deployment/artista-modelcamp-app -n artista
kubectl get certificate -n artista # READY muss True werden (meist < 2 Minuten)
```
**Neuaufbau mit `kubectl delete namespace artista`:** Die PersistentVolumes (`artista-modelcamp-postgres`, `artista-modelcamp-media`) gehören keinem Namespace und bleiben auf `Released` stehen. Die Daten auf dem NAS bleiben erhalten (`Retain`). Damit die neuen Claims sie wieder binden können, vor dem erneuten Anlegen:
```bash
kubectl patch pv artista-modelcamp-postgres -p '{"spec":{"claimRef":null}}'
kubectl patch pv artista-modelcamp-media -p '{"spec":{"claimRef":null}}'
```
Soll die Datenbank wirklich leer neu starten, den Ordner `modelcamp-postgres` auf dem NAS vorher leeren.
## Erstes Admin-Konto
@@ -61,7 +75,9 @@ kubectl rollout restart deployment/artista-modelcamp-app -n artista
## Fehlersuche
```bash
kubectl -n artista logs deploy/artista-modelcamp-app -c migrate # Migration
kubectl -n artista logs deploy/artista-modelcamp-app -c app # App
kubectl -n artista describe certificate artista-modelcamp-tls # Zertifikat
kubectl -n artista get certificate,certificaterequest,order,challenge # Zertifikat
kubectl -n artista describe challenge
kubectl -n artista logs deploy/artista-modelcamp-app -c migrate # Migration
kubectl -n artista logs deploy/artista-modelcamp-app -c app # App
kubectl -n artista get events --sort-by=.lastTimestamp | tail -20
```