- tasks/ldap.yml keeps cn=Harmony (harmony@eom.dev): password from Vault, in Harmony Users, Postfix Users and Dovecot Users. GoTrue sends as it, and it is an instance admin alongside eric@eom.dev. - theme.js hides the e-mail/password form; Register and /register (also in Caddy) go to https://www.eom.dev/members/. - The Dex button uses the square eom.dev icon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
401 lines
13 KiB
Django/Jinja
401 lines
13 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 ns = harmony_namespace ~ '.svc.cluster.local' -%}
|
|
{%- set hosts = [harmony_domain, harmony_api_domain] + ([harmony_voice_domain] if harmony_voice_enabled | bool else []) -%}
|
|
{%- macro federation_env() %}
|
|
- {{ secret('SUPABASE_ANON_KEY', 'ANON_KEY') }}
|
|
- {{ secret('SUPABASE_SERVICE_ROLE_KEY', 'SERVICE_ROLE_KEY') }}
|
|
- {{ secret('REDIS_PASSWORD', 'REDIS_PASSWORD') }}
|
|
- {{ secret('LISTENER_PASSWORD', 'LISTENER_PASSWORD') }}
|
|
- {{ secret('INTERNAL_API_SECRET', 'INTERNAL_API_SECRET') }}
|
|
- {{ secret('VAPID_PUBLIC_KEY', 'VAPID_PUBLIC_KEY') }}
|
|
- {{ secret('VAPID_PRIVATE_KEY', 'VAPID_PRIVATE_KEY') }}
|
|
- {{ secret('LIVEKIT_API_KEY', 'LIVEKIT_API_KEY') }}
|
|
- {{ secret('LIVEKIT_API_SECRET', 'LIVEKIT_API_SECRET') }}
|
|
- {name: NODE_ENV, value: production}
|
|
- {name: INSTANCE_DOMAIN, value: {{ harmony_domain | to_json }}}
|
|
- {name: INSTANCE_NAME, value: {{ harmony_instance_name | to_json }}}
|
|
- {name: API_BASE_URL, value: "https://{{ harmony_domain }}"}
|
|
- {name: CORS_ORIGIN, value: "https://{{ harmony_domain }}"}
|
|
- {name: SUPABASE_URL, value: "http://supabase-kong.{{ ns }}:8000"}
|
|
- {name: PUBLIC_SUPABASE_URL, value: "https://{{ harmony_api_domain }}"}
|
|
- {name: REDIS_URL, value: "redis://:$(REDIS_PASSWORD)@redis.{{ ns }}:6379"}
|
|
- {name: USE_BULLMQ_QUEUE, value: "true"}
|
|
- {name: FEDERATION_LISTENER_URL, value: "postgresql://harmony_listener:$(LISTENER_PASSWORD)@supabase-db.{{ ns }}:5432/postgres"}
|
|
- {name: VAPID_SUBJECT, value: {{ harmony_admin_email | to_json }}}
|
|
- {name: GOTRUE_SMTP_HOST, value: {{ harmony_smtp_host | to_json }}}
|
|
{% if harmony_voice_enabled | bool %}
|
|
- {name: LIVEKIT_URL, value: "ws://livekit.{{ ns }}:7880"}
|
|
- {name: LIVEKIT_PUBLIC_URL, value: "wss://{{ harmony_voice_domain }}"}
|
|
{% endif %}
|
|
{%- endmacro -%}
|
|
{# Redis first: every object is applied and waited for in order. #}
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: {{ harmony_name }}-redis
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('redis') }}
|
|
spec:
|
|
accessModes: [ReadWriteOnce]
|
|
storageClassName: {{ harmony_storage_class }}
|
|
resources:
|
|
requests:
|
|
storage: {{ harmony_redis_storage_size }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: redis
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('redis') }}
|
|
spec:
|
|
selector: {{ selector('redis') }}
|
|
ports:
|
|
- name: redis
|
|
port: 6379
|
|
targetPort: 6379
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-redis
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('redis') }}
|
|
spec:
|
|
replicas: 1
|
|
strategy: {type: Recreate}
|
|
selector:
|
|
matchLabels: {{ selector('redis') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('redis') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
securityContext:
|
|
runAsUser: 999
|
|
runAsGroup: 1000
|
|
fsGroup: 1000
|
|
containers:
|
|
- name: redis
|
|
image: {{ harmony_redis_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
command: [sh, -c, 'exec redis-server --appendonly yes --requirepass "$REDIS_PASSWORD"']
|
|
env:
|
|
- {{ secret('REDIS_PASSWORD', 'REDIS_PASSWORD') }}
|
|
ports:
|
|
- containerPort: 6379
|
|
readinessProbe:
|
|
exec:
|
|
command: [sh, -c, 'redis-cli -a "$REDIS_PASSWORD" --no-auth-warning ping | grep -q PONG']
|
|
periodSeconds: 10
|
|
resources: {{ harmony_resources.redis | to_json }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /data
|
|
volumes:
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: {{ harmony_name }}-redis
|
|
---
|
|
{# ------------------------------------------------------------------- web #}
|
|
{{ service('web', 'web', 80) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-web
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('web') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('web') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('web') }}
|
|
annotations:
|
|
eom.dev/theme-checksum: {{ lookup('ansible.builtin.template', 'config.yml.j2') | hash('sha1') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: web
|
|
image: {{ harmony_web_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
# The image's entrypoint writes /config.json from these.
|
|
env:
|
|
- {{ secret('SUPABASE_ANON_KEY', 'ANON_KEY') }}
|
|
- {name: SUPABASE_URL, value: "https://{{ harmony_api_domain }}"}
|
|
- {name: DOMAIN, value: {{ harmony_domain | to_json }}}
|
|
- {name: INSTANCE_NAME, value: {{ harmony_instance_name | to_json }}}
|
|
- {name: APP_URL, value: "https://{{ harmony_domain }}"}
|
|
ports:
|
|
- containerPort: 80
|
|
readinessProbe:
|
|
httpGet: {path: /, port: 80}
|
|
periodSeconds: 10
|
|
resources: {{ harmony_resources.web | to_json }}
|
|
volumeMounts:
|
|
# The eom.dev Catppuccin theme (files/theme/), linked from index.html
|
|
# by the 50-eom-theme.sh entrypoint hook.
|
|
- name: theme
|
|
mountPath: /usr/share/nginx/html/eom
|
|
- name: theme
|
|
mountPath: /docker-entrypoint.d/50-eom-theme.sh
|
|
subPath: theme.sh
|
|
volumes:
|
|
- name: theme
|
|
configMap:
|
|
name: {{ harmony_name }}-theme
|
|
defaultMode: 0755
|
|
{# ------------------------------------------------------------ federation #}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: federation-server
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('federation-server') }}
|
|
spec:
|
|
selector: {{ selector('federation-server') }}
|
|
ports:
|
|
- name: http
|
|
port: 3001
|
|
targetPort: 3001
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-federation-server
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('federation-server') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('federation-server') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('federation-server') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: federation
|
|
image: {{ harmony_federation_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
{{ federation_env() }}
|
|
- {name: PORT, value: "3001"}
|
|
- {name: FEDERATION_MODE, value: server}
|
|
ports:
|
|
- containerPort: 3001
|
|
readinessProbe:
|
|
httpGet: {path: /health, port: 3001}
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
httpGet: {path: /health, port: 3001}
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 30
|
|
failureThreshold: 3
|
|
resources: {{ harmony_resources.federation | to_json }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-federation-worker
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('federation-worker') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('federation-worker') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('federation-worker') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: federation
|
|
image: {{ harmony_federation_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
{{ federation_env() }}
|
|
- {name: FEDERATION_MODE, value: worker}
|
|
resources: {{ harmony_resources.federation | to_json }}
|
|
{# ----------------------------------------------------------- media cache #}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: media-cache
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('media-cache') }}
|
|
spec:
|
|
selector: {{ selector('media-cache') }}
|
|
ports:
|
|
- name: http
|
|
port: 8080
|
|
targetPort: 8080
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-media-cache
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('media-cache') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('media-cache') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('media-cache') }}
|
|
annotations:
|
|
eom.dev/config-checksum: {{ lookup('ansible.builtin.template', 'media-cache.conf.j2') | hash('sha1') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: nginx
|
|
image: {{ harmony_nginx_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
ports:
|
|
- containerPort: 8080
|
|
readinessProbe:
|
|
tcpSocket: {port: 8080}
|
|
periodSeconds: 10
|
|
resources: {{ harmony_resources.media_cache | to_json }}
|
|
volumeMounts:
|
|
- name: proxy
|
|
mountPath: /etc/nginx/conf.d/default.conf
|
|
subPath: media-cache.conf
|
|
# A cache: losing it costs one upstream fetch per file.
|
|
- name: cache
|
|
mountPath: /var/cache/nginx/media
|
|
volumes:
|
|
- name: proxy
|
|
configMap:
|
|
name: {{ harmony_name }}-proxy
|
|
- name: cache
|
|
emptyDir:
|
|
sizeLimit: {{ harmony_media_cache_storage_size }}
|
|
{# ----------------------------------------------------------------- caddy #}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: caddy
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('caddy') }}
|
|
spec:
|
|
selector: {{ selector('caddy') }}
|
|
ports:
|
|
- name: http
|
|
port: 80
|
|
targetPort: 80
|
|
---
|
|
# Harmony's own router (files/Caddyfile): ActivityPub, link unfurls and the
|
|
# federation API go by path, Accept, User-Agent and cookie to the federation
|
|
# server; public media to the cache; the rest to web or Kong.
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ harmony_name }}-caddy
|
|
namespace: {{ harmony_namespace }}
|
|
{{ meta('caddy') }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{ selector('caddy') }}
|
|
template:
|
|
metadata:
|
|
{{ meta('caddy') }}
|
|
annotations:
|
|
eom.dev/config-checksum: {{ lookup('ansible.builtin.file', role_path ~ '/files/Caddyfile') | hash('sha1') }}
|
|
spec:
|
|
enableServiceLinks: false
|
|
affinity: {{ harmony_affinity | to_json }}
|
|
containers:
|
|
- name: caddy
|
|
image: {{ harmony_caddy_image }}
|
|
imagePullPolicy: {{ harmony_image_pull_policy }}
|
|
env:
|
|
- {name: DOMAIN, value: {{ harmony_domain | to_json }}}
|
|
- {name: DB_DOMAIN, value: {{ harmony_api_domain | to_json }}}
|
|
- {name: LIVEKIT_DOMAIN, value: {{ harmony_voice_domain | to_json }}}
|
|
- {name: ENABLE_VOICE, value: {{ harmony_voice_enabled | bool | string | lower | to_json }}}
|
|
- {name: CADDY_TRUSTED_PROXIES, value: ""}
|
|
- {name: SIGNUP_URL, value: {{ harmony_signup_url | to_json }}}
|
|
ports:
|
|
- containerPort: 80
|
|
readinessProbe:
|
|
tcpSocket: {port: 80}
|
|
periodSeconds: 10
|
|
resources: {{ harmony_resources.caddy | to_json }}
|
|
volumeMounts:
|
|
- name: proxy
|
|
mountPath: /etc/caddy/Caddyfile
|
|
subPath: Caddyfile
|
|
- name: data
|
|
mountPath: /data
|
|
- name: config
|
|
mountPath: /config
|
|
volumes:
|
|
- name: proxy
|
|
configMap:
|
|
name: {{ harmony_name }}-proxy
|
|
- name: data
|
|
emptyDir: {}
|
|
- name: config
|
|
emptyDir: {}
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: {{ harmony_name }}
|
|
namespace: {{ harmony_namespace }}
|
|
labels: {"app.kubernetes.io/name": "harmony", "app.kubernetes.io/instance": "{{ harmony_name }}"}
|
|
annotations: {{ harmony_ingress_annotations | to_json }}
|
|
spec:
|
|
ingressClassName: {{ harmony_ingress_class_name }}
|
|
tls:
|
|
- hosts: {{ hosts | to_json }}
|
|
secretName: {{ harmony_tls_secret_name }}
|
|
rules:
|
|
{% for host in hosts %}
|
|
- host: {{ host }}
|
|
http:
|
|
paths:
|
|
- path: /
|
|
pathType: Prefix
|
|
backend:
|
|
service:
|
|
name: caddy
|
|
port:
|
|
number: 80
|
|
{% endfor %}
|