5155cee5e7
## Why The sonarr/radarr/prowlarr deployments gated app startup on their Postgres database being reachable using a hand-written `psql`-in-a-shell loop running the `postgres:17-alpine` image. Now that `unkin/waitfordb` is released (v0.1.0), replace that inline probe with the purpose-built tool so the wait logic lives in one tested place instead of being copy-pasted per workload. `waitfordb` reads the same `PG*` env as a libpq fallback and exits `0` once `SELECT 1` succeeds under those credentials/database, so the retrofit is a drop-in — the password still never lands in argv. ## Changes - Swap the `wait-for-db` initContainer image from `dockerhub/library/postgres:17-alpine` to `docker-internal/waitfordb:v0.1.0` (pinned, not `latest`) in all three arrstack deployments. - Drop the `sh -c` psql loop `command` — `waitfordb` is the image entrypoint. - Keep the existing `PGHOST/PGPORT/PGDATABASE/PGUSER/PGPASSWORD` env, the `wait-for-db` name, and the resource requests/limits unchanged. - Add `WAITFORDB_TIMEOUT=5m` so a stuck database fails the pod fast, and `WAITFORDB_SSLMODE=disable` to match the in-cluster Postgres. Validated with `kubectl kustomize apps/overlays/au-syd1/arrstack` (builds clean; 3 waitfordb refs, no remaining postgres init image). Reviewed-on: #386 Co-authored-by: unkin-agent <unkin-agent@unkin.net> Co-committed-by: unkin-agent <unkin-agent@unkin.net>
135 lines
4.2 KiB
YAML
135 lines
4.2 KiB
YAML
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: radarr
|
|
namespace: arrstack
|
|
spec:
|
|
# Active-active: the -unkin2 fork keeps all state in the shared Postgres
|
|
# (arrstack-postgres) and coordinates via Postgres advisory locks, so N
|
|
# replicas run concurrently behind the radarr Service. RollingUpdate is safe —
|
|
# no SQLite, no RWO lock.
|
|
replicas: 3
|
|
strategy:
|
|
type: RollingUpdate
|
|
selector:
|
|
matchLabels:
|
|
app: radarr
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: radarr
|
|
spec:
|
|
securityContext:
|
|
# Fork image has no USER (runs as root by default); pin it to a non-root
|
|
# UID and group-write the shared RWX CephFS /config (MediaCover etc.).
|
|
# OnRootMismatch avoids a recursive chown of the whole media tree.
|
|
runAsUser: 1000
|
|
runAsGroup: 1000
|
|
fsGroup: 1000
|
|
fsGroupChangePolicy: OnRootMismatch
|
|
initContainers:
|
|
# Gate the app on its own Postgres database+role being reachable, instead
|
|
# of relying on ArgoCD sync-waves (which deadlock if apps aren't Healthy).
|
|
# waitfordb reads the PG* env as a libpq fallback, so the password never lands in argv.
|
|
- name: wait-for-db
|
|
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/waitfordb:v0.1.0
|
|
env:
|
|
- name: WAITFORDB_TIMEOUT
|
|
value: 5m
|
|
- name: WAITFORDB_SSLMODE
|
|
value: disable
|
|
- name: PGHOST
|
|
value: arrstack-postgres-rw.arrstack.svc.cluster.local
|
|
- name: PGPORT
|
|
value: "5432"
|
|
- name: PGDATABASE
|
|
value: radarr-main
|
|
- name: PGUSER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: radarr-db
|
|
key: username
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: radarr-db
|
|
key: password
|
|
resources:
|
|
requests:
|
|
cpu: 10m
|
|
memory: 32Mi
|
|
limits:
|
|
cpu: 100m
|
|
memory: 64Mi
|
|
containers:
|
|
- name: radarr
|
|
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/radarr:v6.4.2-unkin2
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- /app/Radarr
|
|
args:
|
|
- -nobrowser
|
|
- -data=/config
|
|
# Required: bypass the single-instance guard so multiple replicas
|
|
# can share one /config. Cross-replica safety is the Postgres layer,
|
|
# not a local lock file.
|
|
- -nosingleinstancecheck
|
|
ports:
|
|
- name: http
|
|
containerPort: 7878
|
|
protocol: TCP
|
|
envFrom:
|
|
- configMapRef:
|
|
name: radarr-env
|
|
env:
|
|
- name: Radarr__Postgres__User
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: radarr-db
|
|
key: username
|
|
- name: Radarr__Postgres__Password
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: radarr-db
|
|
key: password
|
|
- name: Radarr__Auth__ApiKey
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: radarr-apikey
|
|
key: apitoken
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /radarr/ping
|
|
port: http
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /radarr/ping
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 256Mi
|
|
limits:
|
|
cpu: "1"
|
|
memory: 1Gi
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: /config
|
|
- name: media-movies
|
|
mountPath: /media/movies
|
|
volumes:
|
|
- name: config
|
|
emptyDir: {}
|
|
- name: media-movies
|
|
persistentVolumeClaim:
|
|
claimName: media-movies
|