Files
claudeandClaude Opus 5.5 7d6eec8963 Harmony on eom.dev: Supabase + Harmony on Kubernetes, Dex sign-in, Catppuccin, LiveKit
Kubernetes port of Harmony 1.9.6's self-host compose stack (Supabase Postgres,
GoTrue, PostgREST, Realtime, storage-api, imgproxy, Kong; Harmony web,
federation server/worker, Redis, media cache, Caddy router; LiveKit) at
harmony.eom.dev, api.harmony.eom.dev and voice.harmony.eom.dev.

- Dex is the only sign-in (GoTrue custom OIDC provider custom:dex); e-mail
  login off; listed addresses become instance admins.
- Upstream bootstrap.sh runs unchanged in a Job through a docker shim.
- Catppuccin Mocha/Latte stylesheet injected into the stock web image.
- Secrets generated once and kept in Secret/harmony.

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

139 lines
4.8 KiB
Django/Jinja

{%- set labels = {'app.kubernetes.io/name': 'harmony', 'app.kubernetes.io/instance': harmony_name, 'app.kubernetes.io/component': 'db'} -%}
{%- set init = {
'migrations/97-_supabase.sql': '_supabase.sql',
'migrations/99-realtime.sql': 'realtime.sql',
'migrations/99-logs.sql': 'logs.sql',
'migrations/99-pooler.sql': 'pooler.sql',
'init-scripts/98-webhooks.sql': 'webhooks.sql',
'init-scripts/99-roles.sql': 'roles.sql',
'init-scripts/99-jwt.sql': 'jwt.sql',
} -%}
apiVersion: v1
kind: Service
metadata:
name: supabase-db
namespace: {{ harmony_namespace }}
labels: {{ labels | to_json }}
spec:
selector:
app.kubernetes.io/instance: {{ harmony_name }}
app.kubernetes.io/component: db
ports:
- name: postgres
port: 5432
targetPort: postgres
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ harmony_name }}-db
namespace: {{ harmony_namespace }}
labels: {{ labels | to_json }}
spec:
serviceName: supabase-db
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: {{ harmony_name }}
app.kubernetes.io/component: db
template:
metadata:
labels: {{ labels | to_json }}
spec:
enableServiceLinks: false
affinity: {{ harmony_affinity | to_json }}
terminationGracePeriodSeconds: 60
initContainers:
# Docker seeds a new named volume from the image; a PVC starts empty.
# postgresql.conf includes supautils.conf and others from here, and
# pgsodium's root key is written here on first start.
- name: seed-config
image: {{ harmony_postgres_image }}
imagePullPolicy: {{ harmony_image_pull_policy }}
# The image's postgresql.conf fixes data_directory at the volume's
# root, which the server only uses if postgres owns it (mode 0700).
command: [sh, -c, 'cp -an /etc/postgresql-custom/. /seed/ && chown -R postgres:postgres /seed && chown postgres:postgres /data && chmod 0700 /data']
volumeMounts:
- name: config
mountPath: /seed
- name: data
mountPath: /data
containers:
- name: postgres
image: {{ harmony_postgres_image }}
imagePullPolicy: {{ harmony_image_pull_policy }}
args:
- postgres
- -c
- config_file=/etc/postgresql/postgresql.conf
# Keeps Realtime's polling queries out of the logs.
- -c
- log_min_messages=fatal
env:
- name: POSTGRES_PASSWORD
valueFrom: {secretKeyRef: {name: {{ harmony_name }}, key: POSTGRES_PASSWORD}}
- name: PGPASSWORD
valueFrom: {secretKeyRef: {name: {{ harmony_name }}, key: POSTGRES_PASSWORD}}
- name: JWT_SECRET
valueFrom: {secretKeyRef: {name: {{ harmony_name }}, key: JWT_SECRET}}
- {name: JWT_EXP, value: "3600"}
- {name: POSTGRES_HOST, value: /var/run/postgresql}
- {name: PGPORT, value: "5432"}
- {name: POSTGRES_PORT, value: "5432"}
- {name: PGDATABASE, value: postgres}
- {name: POSTGRES_DB, value: postgres}
ports:
- name: postgres
containerPort: 5432
readinessProbe:
exec:
command: [pg_isready, -U, postgres, -h, localhost]
periodSeconds: 5
failureThreshold: 6
livenessProbe:
exec:
command: [pg_isready, -U, postgres, -h, localhost]
initialDelaySeconds: 120
periodSeconds: 30
failureThreshold: 6
resources: {{ harmony_resources.db | to_json }}
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
# pgsodium's root key lives here; it must outlive the pod.
- name: config
mountPath: /etc/postgresql-custom
- name: shm
mountPath: /dev/shm
{% for path, file in init | dictsort %}
- name: init
mountPath: /docker-entrypoint-initdb.d/{{ path }}
subPath: {{ file }}
{% endfor %}
volumes:
- name: init
configMap:
name: {{ harmony_name }}-db-init
# Parallel VACUUM and CREATE INDEX need more than the default 64 MB.
- name: shm
emptyDir:
medium: Memory
sizeLimit: 1Gi
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ReadWriteOnce]
storageClassName: {{ harmony_storage_class }}
resources:
requests:
storage: {{ harmony_db_storage_size }}
- metadata:
name: config
spec:
accessModes: [ReadWriteOnce]
storageClassName: {{ harmony_storage_class }}
resources:
requests:
storage: {{ harmony_db_config_storage_size }}