- Add MigrationLock module using PostgreSQL advisory locks - Prevent concurrent migrations across multiple nodes - Update Release.migrate to use distributed lock when cluster enabled - Disable auto-migrations in cluster mode to avoid race conditions - Add init container configuration for Kubernetes deployments - Document migration strategies in k8s/README-migrations.md This ensures only one node runs database migrations at a time, preventing conflicts and race conditions in distributed deployments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
No EOL
928 B
YAML
37 lines
No EOL
928 B
YAML
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: aprs
|
|
namespace: aprs
|
|
spec:
|
|
template:
|
|
spec:
|
|
initContainers:
|
|
- name: migrate
|
|
image: ghcr.io/aprsme/aprs.me:latest
|
|
imagePullPolicy: Always
|
|
command: ["/app/bin/migrate"]
|
|
env:
|
|
- name: DATABASE_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: database-url-pgbouncer
|
|
name: aprs-secret
|
|
- name: SECRET_KEY_BASE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: secret-key-base
|
|
name: aprs-secret
|
|
- name: MIX_ENV
|
|
value: prod
|
|
- name: SKIP_DB_CREATE
|
|
value: "true"
|
|
- name: CLUSTER_ENABLED
|
|
value: "false" # Disable clustering for migration runner
|
|
resources:
|
|
limits:
|
|
cpu: 200m
|
|
memory: 256Mi
|
|
requests:
|
|
cpu: 100m
|
|
memory: 128Mi |