Documents, avatars and the encrypted app backups lived in ./uploads and ./backups inside the container and were lost on every restart. The backend now mounts the apicore-data volume at /data (configmap paths /data/documents and /data/backups). Both deployments pin the image to a CI build (sha-<commit>) with imagePullPolicy IfNotPresent instead of :latest, run as uid 1000 with seccomp RuntimeDefault, no privilege escalation and all capabilities dropped. The frontend gets a liveness probe. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
82 lines
2.6 KiB
YAML
82 lines
2.6 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: apicore-backend
|
|
labels:
|
|
app: apicore-backend
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: apicore-backend
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: apicore-backend
|
|
spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 1000
|
|
runAsGroup: 1000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
volumes:
|
|
# Dokumente, Avatare und App-Backups (DOCUMENTS_STORAGE_PATH /
|
|
# BACKUP_STORAGE_PATH unter /data). Ohne Volume landen sie im
|
|
# Container und sind beim naechsten Neustart weg.
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: apicore-data
|
|
containers:
|
|
- name: apicore-backend
|
|
# Fest auf einen Build pinnen (Tag sha-<commit> aus der CI oder Digest),
|
|
# nicht :latest - sonst gibt es kein Rollback und jeder Neustart zieht
|
|
# ungeprueft das neueste Image. Ausrollen:
|
|
# kubectl -n apicore set image deploy/apicore-backend \
|
|
# apicore-backend=git.encry.de/nick.rosenloecher/apicore-backend:sha-<commit>
|
|
image: git.encry.de/nick.rosenloecher/apicore-backend:sha-REPLACE_ME
|
|
imagePullPolicy: IfNotPresent
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /data
|
|
ports:
|
|
- containerPort: 3001
|
|
envFrom:
|
|
- configMapRef:
|
|
name: apicore-backend-config
|
|
- secretRef:
|
|
name: apicore-backend-secret
|
|
# Container fuehrt beim Start selbst `prisma migrate deploy` aus,
|
|
# bevor der Server Verbindungen annimmt (siehe Dockerfile CMD) -
|
|
# startupProbe gibt dafuer bis zu 5 Minuten Zeit, ohne dass
|
|
# liveness/readiness in der Zwischenzeit einen Neustart ausloesen.
|
|
startupProbe:
|
|
httpGet:
|
|
path: /health/ready
|
|
port: 3001
|
|
failureThreshold: 30
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 3001
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 15
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health/ready
|
|
port: 3001
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
resources:
|
|
requests:
|
|
cpu: "0"
|
|
memory: "0"
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|