Files
infra-prod/deploy/affine/deployment.yaml
2025-06-02 01:32:49 +02:00

105 lines
3.3 KiB
YAML

# --------------------------------------------------------------------
# 5a) Job: affine-migration (runs once at startup to initialize the DB)
# --------------------------------------------------------------------
apiVersion: batch/v1
kind: Job
metadata:
name: affine-migration
namespace: affine
spec:
backoffLimit: 2
template:
metadata:
labels:
job: affine-migration
spec:
restartPolicy: OnFailure
containers:
- name: affine-migrate
image: ghcr.io/toeverything/affine-graphql:${AFFINE_REVISION:-stable}
command: ["sh", "-c", "node ./scripts/self-host-predeploy.js"]
env:
- name: REDIS_SERVER_HOST
value: "redis-lb.redis.svc.cluster.local:6379"
- name: DATABASE_URL
value: >-
postgresql://$(DB_USERNAME):$(DB_PASSWORD)@postgres-base-rw.postgres.svc.cluster.local:5432/$(DB_DATABASE)
envFrom:
- secretRef:
name: affine-db-secret
volumeMounts:
- name: affine-storage
mountPath: /root/.affine/storage
- name: affine-config
mountPath: /root/.affine/config
volumes:
- name: affine-storage
persistentVolumeClaim:
claimName: affine-storage-pvc
- name: affine-config
persistentVolumeClaim:
claimName: affine-config-pvc
---
# --------------------------------------------------------------------
# 5b) Deployment: affine-server (serves HTTP on port 3010)
# --------------------------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: affine-server
namespace: affine
labels:
app: affine-server
spec:
replicas: 1
selector:
matchLabels:
app: affine-server
template:
metadata:
labels:
app: affine-server
spec:
containers:
- name: affine
image: ghcr.io/toeverything/affine-graphql:stable
ports:
- containerPort: 3010
name: http
env:
- name: REDIS_SERVER_HOST
value: "redis-lb.redis.svc.cluster.local:6379"
- name: DATABASE_URL
value: >-
postgresql://$(DB_USERNAME):$(DB_PASSWORD)@postgres-base-rw.postgres.svc.cluster.local:5432/$(DB_DATABASE)
- name: AFFINE_SERVER_EXTERNAL_URL
value: "https://affine.prod.panic.haus"
envFrom:
- secretRef:
name: affine-db-secret
readinessProbe:
# If Affine supports an HTTP health endpoint, replace “/health” with the actual path.
httpGet:
path: /health
port: 3010
initialDelaySeconds: 10
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 3010
initialDelaySeconds: 30
periodSeconds: 20
volumeMounts:
- name: affine-storage
mountPath: /root/.affine/storage
- name: affine-config
mountPath: /root/.affine/config
volumes:
- name: affine-storage
persistentVolumeClaim:
claimName: affine-storage-pvc
- name: affine-config
persistentVolumeClaim:
claimName: affine-config-pvc