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>
376 lines
15 KiB
Django/Jinja
376 lines
15 KiB
Django/Jinja
{%- macro secret(name, key) -%}
|
|
{name: {{ name }}, valueFrom: {secretKeyRef: {name: {{ harmony_name }}, key: {{ key }}}}}
|
|
{%- endmacro -%}
|
|
{%- macro meta(component) -%}
|
|
labels: {"app.kubernetes.io/name": "harmony", "app.kubernetes.io/instance": "{{ harmony_name }}", "app.kubernetes.io/component": "{{ component }}"}
|
|
{%- endmacro -%}
|
|
{%- macro selector(component) -%}
|
|
{"app.kubernetes.io/instance": "{{ harmony_name }}", "app.kubernetes.io/component": "{{ component }}"}
|
|
{%- endmacro -%}
|
|
{%- macro service(name, component, port) -%}
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ name }}
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta(component) }}
|
|
spec:
|
|
selector: {{ selector(component) }}
|
|
ports:
|
|
- name: http
|
|
port: {{ port }}
|
|
targetPort: {{ port }}
|
|
{%- endmacro -%}
|
|
{%- set db = 'supabase-db.' ~ harmony_namespace ~ '.svc.cluster.local' -%}
|
|
{%- set allow_list = ['https://' ~ harmony_domain, 'tauri://localhost/**', 'http://tauri.localhost/**'] -%}
|
|
{#- ------------------------------------------------------------------ auth -#}
|
|
{{ service('auth', 'auth', 9999) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-auth
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('auth') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('auth') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('auth') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: gotrue
|
|
image: {{ harmony_gotrue_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
- {{ secret('POSTGRES_PASSWORD', 'POSTGRES_PASSWORD') }}
|
|
- {{ secret('GOTRUE_JWT_SECRET', 'JWT_SECRET') }}
|
|
- {{ secret('GOTRUE_SMTP_PASS', 'SMTP_PASS') }}
|
|
- {name: GOTRUE_API_HOST, value: 0.0.0.0}
|
|
- {name: GOTRUE_API_PORT, value: "9999"}
|
|
- {name: API_EXTERNAL_URL, value: "https://{{ harmony_api_domain }}"}
|
|
- {name: GOTRUE_DB_DRIVER, value: postgres}
|
|
- {name: GOTRUE_DB_DATABASE_URL, value: "postgres://supabase_auth_admin:$(POSTGRES_PASSWORD)@{{ db }}:5432/postgres"}
|
|
- {name: GOTRUE_SITE_URL, value: "https://{{ harmony_domain }}"}
|
|
- {name: GOTRUE_URI_ALLOW_LIST, value: {{ allow_list | join(',') | to_json }}}
|
|
# Sign-up stays on: a first sign-in through Dex makes the account.
|
|
- {name: GOTRUE_DISABLE_SIGNUP, value: "false"}
|
|
- {name: GOTRUE_JWT_ADMIN_ROLES, value: service_role}
|
|
- {name: GOTRUE_JWT_AUD, value: authenticated}
|
|
- {name: GOTRUE_JWT_DEFAULT_GROUP_NAME, value: authenticated}
|
|
- {name: GOTRUE_JWT_EXP, value: "3600"}
|
|
- {name: GOTRUE_EXTERNAL_EMAIL_ENABLED, value: {{ harmony_email_login | bool | string | lower | to_json }}}
|
|
- {name: GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED, value: "false"}
|
|
- {name: GOTRUE_MAILER_AUTOCONFIRM, value: "false"}
|
|
- {name: GOTRUE_SMTP_ADMIN_EMAIL, value: {{ harmony_smtp_sender | to_json }}}
|
|
- {name: GOTRUE_SMTP_HOST, value: {{ harmony_smtp_host | to_json }}}
|
|
- {name: GOTRUE_SMTP_PORT, value: {{ harmony_smtp_port | string | to_json }}}
|
|
- {name: GOTRUE_SMTP_USER, value: {{ harmony_smtp_username | to_json }}}
|
|
- {name: GOTRUE_SMTP_SENDER_NAME, value: {{ harmony_instance_name | to_json }}}
|
|
- {name: GOTRUE_MAILER_URLPATHS_INVITE, value: /auth/v1/verify}
|
|
- {name: GOTRUE_MAILER_URLPATHS_CONFIRMATION, value: /auth/v1/verify}
|
|
- {name: GOTRUE_MAILER_URLPATHS_RECOVERY, value: /auth/v1/verify}
|
|
- {name: GOTRUE_MAILER_URLPATHS_EMAIL_CHANGE, value: /auth/v1/verify}
|
|
- {name: GOTRUE_MAILER_TEMPLATES_INVITE, value: "http://web.{{ harmony_namespace }}.svc.cluster.local/email-templates/invite.html"}
|
|
- {name: GOTRUE_MAILER_TEMPLATES_RECOVERY, value: "http://web.{{ harmony_namespace }}.svc.cluster.local/email-templates/recovery.html"}
|
|
- {name: GOTRUE_EXTERNAL_PHONE_ENABLED, value: "false"}
|
|
- {name: GOTRUE_SMS_AUTOCONFIRM, value: "false"}
|
|
# Harmony's supabase-overrides.yml.
|
|
- {name: GOTRUE_SECURITY_SB_FORWARDED_FOR_ENABLED, value: "true"}
|
|
- {name: GOTRUE_HOOK_BEFORE_USER_CREATED_ENABLED, value: "true"}
|
|
- {name: GOTRUE_HOOK_BEFORE_USER_CREATED_URI, value: "pg-functions://postgres/public/before_user_created_hook"}
|
|
- {name: GOTRUE_RATE_LIMIT_EMAIL_SENT, value: "100"}
|
|
- {name: GOTRUE_CUSTOM_OAUTH_ENABLED, value: "true"}
|
|
- {name: GOTRUE_CUSTOM_OAUTH_EXTERNAL_URL, value: "https://{{ harmony_api_domain }}/auth/v1"}
|
|
# A Dex sign-in never joins an account by e-mail address.
|
|
- {name: GOTRUE_EXPERIMENTAL_PROVIDER_LINKING_DOMAINS, value: "custom:{{ harmony_oidc_provider_id }}=custom:{{ harmony_oidc_provider_id }}"}
|
|
ports:
|
|
- containerPort: 9999
|
|
readinessProbe:
|
|
httpGet: {path: /health, port: 9999}
|
|
periodSeconds: 5
|
|
livenessProbe:
|
|
httpGet: {path: /health, port: 9999}
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 30
|
|
resources: {{ harmony_resources.auth | to_json }}
|
|
{# ------------------------------------------------------------------ rest #}
|
|
---
|
|
{{ service('rest', 'rest', 3000) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-rest
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('rest') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('rest') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('rest') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: postgrest
|
|
image: {{ harmony_postgrest_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
args: [postgrest]
|
|
env:
|
|
- {{ secret('POSTGRES_PASSWORD', 'POSTGRES_PASSWORD') }}
|
|
- {{ secret('PGRST_JWT_SECRET', 'JWT_SECRET') }}
|
|
- {name: PGRST_DB_URI, value: "postgres://authenticator:$(POSTGRES_PASSWORD)@{{ db }}:5432/postgres"}
|
|
- {name: PGRST_DB_SCHEMAS, value: "public,storage,graphql_public"}
|
|
- {name: PGRST_DB_ANON_ROLE, value: anon}
|
|
- {name: PGRST_DB_USE_LEGACY_GUCS, value: "false"}
|
|
- {name: PGRST_APP_SETTINGS_JWT_EXP, value: "3600"}
|
|
ports:
|
|
- containerPort: 3000
|
|
readinessProbe:
|
|
tcpSocket: {port: 3000}
|
|
periodSeconds: 5
|
|
resources: {{ harmony_resources.rest | to_json }}
|
|
{# -------------------------------------------------------------- realtime #}
|
|
---
|
|
# Named realtime-dev: Realtime takes the tenant from the first label of the
|
|
# Host header Kong sends (see kong.yml.j2).
|
|
{{ service('realtime-dev', 'realtime', 4000) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-realtime
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('realtime') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('realtime') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('realtime') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: realtime
|
|
image: {{ harmony_realtime_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
- {{ secret('DB_PASSWORD', 'POSTGRES_PASSWORD') }}
|
|
- {{ secret('API_JWT_SECRET', 'JWT_SECRET') }}
|
|
- {{ secret('METRICS_JWT_SECRET', 'JWT_SECRET') }}
|
|
- {{ secret('SECRET_KEY_BASE', 'SECRET_KEY_BASE') }}
|
|
- {name: PORT, value: "4000"}
|
|
- {name: DB_HOST, value: {{ db | to_json }}}
|
|
- {name: DB_PORT, value: "5432"}
|
|
- {name: DB_USER, value: supabase_admin}
|
|
- {name: DB_NAME, value: postgres}
|
|
- {name: DB_AFTER_CONNECT_QUERY, value: "SET search_path TO _realtime"}
|
|
- {name: DB_ENC_KEY, value: supabaserealtime}
|
|
- {name: ERL_AFLAGS, value: "-proto_dist inet_tcp"}
|
|
- {name: DNS_NODES, value: "''"}
|
|
- {name: RLIMIT_NOFILE, value: "10000"}
|
|
- {name: APP_NAME, value: realtime}
|
|
- {name: SEED_SELF_HOST, value: "true"}
|
|
- {name: RUN_JANITOR, value: "true"}
|
|
# Harmony's supabase-overrides.yml (see the comments there).
|
|
- {name: CLIENT_PRESENCE_MAX_CALLS, value: "60"}
|
|
- {name: CLIENT_PRESENCE_WINDOW_MS, value: "30000"}
|
|
- {name: CHANNEL_ERROR_BACKOFF_MS, value: "100"}
|
|
- {name: TENANT_MAX_CONCURRENT_USERS, value: "9000"}
|
|
- {name: TENANT_MAX_JOINS_PER_SECOND, value: "100000"}
|
|
- {name: TENANT_MAX_EVENTS_PER_SECOND, value: "1000000"}
|
|
ports:
|
|
- containerPort: 4000
|
|
# Like the compose health check, this also makes Realtime run its
|
|
# tenant migrations (realtime.messages, realtime.send), which the
|
|
# bootstrap Job waits for. The anon key is public (config.json).
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /api/tenants/realtime-dev/health
|
|
port: 4000
|
|
httpHeaders:
|
|
- name: Authorization
|
|
value: "Bearer {{ _harmony_secrets.ANON_KEY }}"
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
failureThreshold: 30
|
|
resources: {{ harmony_resources.realtime | to_json }}
|
|
{# --------------------------------------------------------------- storage #}
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: {{ harmony_name }}-files
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('storage') }}
|
|
spec:
|
|
accessModes: [ReadWriteMany]
|
|
storageClassName: {{ harmony_storage_class }}
|
|
resources:
|
|
requests:
|
|
storage: {{ harmony_files_storage_size }}
|
|
---
|
|
{{ service('storage', 'storage', 5000) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-storage
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('storage') }}
|
|
spec:
|
|
replicas: 1
|
|
strategy: {type: Recreate}
|
|
selector:
|
|
matchLabels: {{ selector('storage') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('storage') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: storage
|
|
image: {{ harmony_storage_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
- {{ secret('POSTGRES_PASSWORD', 'POSTGRES_PASSWORD') }}
|
|
- {{ secret('ANON_KEY', 'ANON_KEY') }}
|
|
- {{ secret('SERVICE_KEY', 'SERVICE_ROLE_KEY') }}
|
|
- {{ secret('PGRST_JWT_SECRET', 'JWT_SECRET') }}
|
|
- {name: POSTGREST_URL, value: "http://rest.{{ harmony_namespace }}.svc.cluster.local:3000"}
|
|
- {name: DATABASE_URL, value: "postgres://supabase_storage_admin:$(POSTGRES_PASSWORD)@{{ db }}:5432/postgres"}
|
|
- {name: FILE_SIZE_LIMIT, value: {{ harmony_file_size_limit | string | to_json }}}
|
|
- {name: STORAGE_BACKEND, value: file}
|
|
- {name: FILE_STORAGE_BACKEND_PATH, value: /var/lib/storage}
|
|
- {name: TENANT_ID, value: stub}
|
|
- {name: REGION, value: stub}
|
|
- {name: GLOBAL_S3_BUCKET, value: stub}
|
|
- {name: ENABLE_IMAGE_TRANSFORMATION, value: "true"}
|
|
- {name: IMGPROXY_URL, value: "http://imgproxy.{{ harmony_namespace }}.svc.cluster.local:5001"}
|
|
ports:
|
|
- containerPort: 5000
|
|
readinessProbe:
|
|
httpGet: {path: /status, port: 5000}
|
|
periodSeconds: 5
|
|
resources: {{ harmony_resources.storage | to_json }}
|
|
volumeMounts:
|
|
- name: files
|
|
mountPath: /var/lib/storage
|
|
volumes:
|
|
- name: files
|
|
persistentVolumeClaim:
|
|
claimName: {{ harmony_name }}-files
|
|
{# -------------------------------------------------------------- imgproxy #}
|
|
---
|
|
{{ service('imgproxy', 'imgproxy', 5001) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-imgproxy
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('imgproxy') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('imgproxy') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('imgproxy') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: imgproxy
|
|
image: {{ harmony_imgproxy_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
- {name: IMGPROXY_BIND, value: ":5001"}
|
|
- {name: IMGPROXY_LOCAL_FILESYSTEM_ROOT, value: /}
|
|
- {name: IMGPROXY_USE_ETAG, value: "true"}
|
|
- {name: IMGPROXY_AUTO_WEBP, value: "true"}
|
|
- {name: IMGPROXY_PREFERRED_FORMATS, value: "jpeg,png,gif,webp,avif"}
|
|
- {name: IMGPROXY_MAX_SRC_RESOLUTION, value: "50"}
|
|
- {name: IMGPROXY_MAX_ANIMATION_FRAMES, value: "120"}
|
|
ports:
|
|
- containerPort: 5001
|
|
readinessProbe:
|
|
httpGet: {path: /health, port: 5001}
|
|
periodSeconds: 5
|
|
resources: {{ harmony_resources.imgproxy | to_json }}
|
|
volumeMounts:
|
|
- name: files
|
|
mountPath: /var/lib/storage
|
|
readOnly: true
|
|
volumes:
|
|
- name: files
|
|
persistentVolumeClaim:
|
|
claimName: {{ harmony_name }}-files
|
|
{# ------------------------------------------------------------------ kong #}
|
|
---
|
|
{{ service('supabase-kong', 'kong', 8000) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-kong
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('kong') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('kong') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('kong') }}
|
|
annotations:
|
|
eom.dev/config-checksum: {{ lookup('ansible.builtin.template', 'kong.yml.j2') | hash('sha1') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: kong
|
|
image: {{ harmony_kong_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
# Expands the keys into the declarative config, as the compose stack does.
|
|
command:
|
|
- bash
|
|
- -c
|
|
- eval "echo \"$(cat /home/kong/temp.yml)\"" > /usr/local/kong/kong.yml && exec /docker-entrypoint.sh kong docker-start
|
|
env:
|
|
- {{ secret('SUPABASE_ANON_KEY', 'ANON_KEY') }}
|
|
- {{ secret('SUPABASE_SERVICE_KEY', 'SERVICE_ROLE_KEY') }}
|
|
- {name: KONG_DATABASE, value: "off"}
|
|
- {name: KONG_DECLARATIVE_CONFIG, value: /usr/local/kong/kong.yml}
|
|
- {name: KONG_DNS_ORDER, value: "LAST,A,CNAME"}
|
|
- {name: KONG_DNS_VALID_TTL, value: "5"}
|
|
- {name: KONG_DNS_NOT_FOUND_TTL, value: "1"}
|
|
- {name: KONG_PLUGINS, value: "request-transformer,cors,key-auth,acl,basic-auth"}
|
|
- {name: KONG_NGINX_PROXY_PROXY_BUFFER_SIZE, value: 160k}
|
|
- {name: KONG_NGINX_PROXY_PROXY_BUFFERS, value: "64 160k"}
|
|
- {name: KONG_PROXY_ACCESS_LOG, value: "/dev/stdout combined"}
|
|
ports:
|
|
- containerPort: 8000
|
|
readinessProbe:
|
|
tcpSocket: {port: 8000}
|
|
periodSeconds: 5
|
|
resources: {{ harmony_resources.kong | to_json }}
|
|
volumeMounts:
|
|
- name: proxy
|
|
mountPath: /home/kong/temp.yml
|
|
subPath: kong.yml
|
|
volumes:
|
|
- name: proxy
|
|
configMap:
|
|
name: {{ harmony_name }}-proxy
|