Files
claudeandClaude Opus 5.5 96f06e332a Keep Funkwhale pods on one node and declare their disk use
alpha-worker nodes have 15.6 GiB roots with a few GiB free; pulling the
1 GiB api image onto several of them at once tripped DiskPressure and
evicted the pods. Prefer co-locating every Funkwhale pod so the image is
pulled once, and request ephemeral storage so the scheduler skips nearly
full nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 15:31:15 -05:00

93 lines
3.1 KiB
Django/Jinja

{%- set _colocate = {'podAffinity': {'preferredDuringSchedulingIgnoredDuringExecution': [{'weight': 100, 'podAffinityTerm': {'topologyKey': 'kubernetes.io/hostname', 'labelSelector': {'matchLabels': {'app.kubernetes.io/instance': funkwhale_name}}}}]}} -%}
{%- set _funkwhale_affinity = funkwhale_affinity | combine(_colocate) if funkwhale_colocate | bool else funkwhale_affinity -%}
apiVersion: v1
kind: Service
metadata:
name: {{ funkwhale_name }}-db
namespace: {{ funkwhale_namespace }}
labels:
app.kubernetes.io/name: funkwhale
app.kubernetes.io/instance: {{ funkwhale_name }}
app.kubernetes.io/component: database
spec:
clusterIP: None
selector:
app.kubernetes.io/instance: {{ funkwhale_name }}
app.kubernetes.io/component: database
ports:
- name: postgres
port: 5432
targetPort: postgres
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ funkwhale_name }}-db
namespace: {{ funkwhale_namespace }}
labels:
app.kubernetes.io/name: funkwhale
app.kubernetes.io/instance: {{ funkwhale_name }}
app.kubernetes.io/component: database
spec:
serviceName: {{ funkwhale_name }}-db
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: {{ funkwhale_name }}
app.kubernetes.io/component: database
template:
metadata:
labels:
app.kubernetes.io/name: funkwhale
app.kubernetes.io/instance: {{ funkwhale_name }}
app.kubernetes.io/component: database
spec:
# postgres:*-alpine runs as uid/gid 70. Running unprivileged skips the
# entrypoint's chown, which NFS with root_squash would refuse.
securityContext:
runAsUser: 70
runAsGroup: 70
fsGroup: 70
affinity: {{ _funkwhale_affinity | to_json }}
containers:
- name: postgres
image: {{ funkwhale_postgres_image }}
imagePullPolicy: {{ funkwhale_image_pull_policy }}
env:
- name: POSTGRES_USER
value: funkwhale
- name: POSTGRES_DB
value: funkwhale
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ funkwhale_name }}
key: POSTGRES_PASSWORD
ports:
- name: postgres
containerPort: 5432
readinessProbe:
exec:
command: [pg_isready, -U, funkwhale, -d, funkwhale]
periodSeconds: 10
livenessProbe:
exec:
command: [pg_isready, -U, funkwhale, -d, funkwhale]
initialDelaySeconds: 30
periodSeconds: 30
resources: {{ funkwhale_postgres_resources | to_json }}
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ReadWriteOnce]
storageClassName: {{ funkwhale_storage_class }}
resources:
requests:
storage: {{ funkwhale_db_storage_size }}