- Add migration init container that runs before main app containers - Ensures database migrations are applied on every deployment - Includes all necessary environment variables for migration execution - Disable AUTO_MIGRATE in main container since init container handles it - Prevents race conditions by running migrations before cluster formation This resolves issues where migrations weren't running in cluster mode and ensures new deployments always have the latest schema changes.
218 lines
No EOL
6.2 KiB
YAML
218 lines
No EOL
6.2 KiB
YAML
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: aprs-headless
|
|
namespace: aprs
|
|
spec:
|
|
clusterIP: None
|
|
selector:
|
|
app: aprs
|
|
ports:
|
|
- name: epmd
|
|
port: 4369
|
|
targetPort: 4369
|
|
- name: erlang
|
|
port: 9100
|
|
targetPort: 9100
|
|
- name: gossip
|
|
port: 45892
|
|
targetPort: 45892
|
|
protocol: UDP
|
|
publishNotReadyAddresses: true
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: aprs
|
|
namespace: aprs
|
|
spec:
|
|
serviceName: aprs-headless
|
|
replicas: 2
|
|
updateStrategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
partition: 0
|
|
podManagementPolicy: Parallel
|
|
selector:
|
|
matchLabels:
|
|
app: aprs
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: aprs
|
|
spec:
|
|
terminationGracePeriodSeconds: 60
|
|
serviceAccountName: aprs-service-account
|
|
imagePullSecrets:
|
|
- name: ghcr-pull-secret
|
|
initContainers:
|
|
- name: wait-for-db
|
|
image: busybox:1.36.1
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for PostgreSQL at 10.0.19.220:5432..."
|
|
until nc -z 10.0.19.220 5432; do
|
|
echo "Database not ready, waiting..."
|
|
sleep 2
|
|
done
|
|
echo "Database is ready!"
|
|
- name: wait-for-redis
|
|
image: busybox:1.36.1
|
|
command:
|
|
- sh
|
|
- -c
|
|
- until nc -z redis 6379; do echo waiting for redis; sleep 2; done
|
|
- name: migrate
|
|
image: ghcr.io/aprsme/aprs.me:latest
|
|
imagePullPolicy: Always
|
|
command: ["/app/bin/aprsme", "eval", "Aprsme.Release.migrate()"]
|
|
env:
|
|
- name: DATABASE_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-url
|
|
- name: DATABASE_SSL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-ssl
|
|
- name: DATABASE_SSL_VERIFY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-ssl-verify
|
|
- name: SECRET_KEY_BASE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: secret-key-base
|
|
- name: MIX_ENV
|
|
value: "prod"
|
|
- name: POOL_SIZE
|
|
value: "1"
|
|
- name: SKIP_DB_CREATE
|
|
value: "true"
|
|
- name: REDIS_URL
|
|
value: "redis://redis.aprs.svc.cluster.local:6379"
|
|
- name: PHX_HOST
|
|
value: "aprs.me"
|
|
- name: PORT
|
|
value: "4000"
|
|
- name: APRS_CALLSIGN
|
|
value: "W5ISP-1"
|
|
- name: APRS_FILTER
|
|
value: "r/33/-96/1000000000000"
|
|
- name: APRS_PASSCODE
|
|
value: "15748"
|
|
- name: APRS_PORT
|
|
value: "10152"
|
|
- name: APRS_SERVER
|
|
value: "dallas.aprs2.net"
|
|
containers:
|
|
- name: aprs
|
|
image: ghcr.io/aprsme/aprs.me:latest
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 4000
|
|
- containerPort: 4369
|
|
name: epmd
|
|
- containerPort: 9100
|
|
name: erlang
|
|
- containerPort: 45892
|
|
name: gossip
|
|
protocol: UDP
|
|
env:
|
|
- name: PHX_HOST
|
|
value: "aprs.me"
|
|
- name: PORT
|
|
value: "4000"
|
|
- name: DATABASE_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-url
|
|
- name: DATABASE_SSL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-ssl
|
|
- name: DATABASE_SSL_VERIFY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: database-ssl-verify
|
|
- name: SECRET_KEY_BASE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: secret-key-base
|
|
- name: PHX_SERVER
|
|
value: "true"
|
|
- name: MIX_ENV
|
|
value: "prod"
|
|
- name: APRS_CALLSIGN
|
|
value: "W5ISP-1"
|
|
- name: APRS_FILTER
|
|
value: "r/33/-96/1000000000000"
|
|
- name: APRS_PASSCODE
|
|
value: "15748"
|
|
- name: APRS_PORT
|
|
value: "10152"
|
|
- name: APRS_SERVER
|
|
value: "dallas.aprs2.net"
|
|
- name: PACKET_RETENTION_DAYS
|
|
value: "7"
|
|
- name: POOL_SIZE
|
|
value: "5"
|
|
- name: CLUSTER_ENABLED
|
|
value: "true"
|
|
- name: RELEASE_COOKIE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: aprs-secret
|
|
key: erlang-cookie
|
|
- name: POD_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: POD_NAMESPACE
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
- name: POD_IP
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: status.podIP
|
|
- name: REDIS_URL
|
|
value: "redis://redis.aprs.svc.cluster.local:6379"
|
|
- name: DRAIN_TIMEOUT_MS
|
|
value: "45000"
|
|
- name: SKIP_DB_CREATE
|
|
value: "true" # Database already exists on external server
|
|
- name: AUTO_MIGRATE
|
|
value: "false" # Disabled - migrations now handled by init container
|
|
resources:
|
|
limits:
|
|
memory: "1Gi"
|
|
requests:
|
|
memory: "1Gi"
|
|
cpu: "500m"
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 4000
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 4000
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 5
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command: ["/bin/sh", "-c", "sleep 15"] |