Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(supabase): fix supabase-realtime #855

Merged
merged 47 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f652a16
Adds separate supabase realtime config for websocket/api
CollectiveUnicorn Aug 2, 2024
4b3fd69
Updates the default config with necessary vars
CollectiveUnicorn Aug 2, 2024
f6d4166
Adds init container placeholder for seeding tables via curl
CollectiveUnicorn Aug 2, 2024
775339b
Moves configmap changes to extra configs
CollectiveUnicorn Aug 2, 2024
e6d5394
Renames variable for compatbility with supabase version
CollectiveUnicorn Aug 2, 2024
427ffce
Ensures configmap is mounted in container
CollectiveUnicorn Aug 2, 2024
7ba8566
Specify the variables manuallY
CollectiveUnicorn Aug 2, 2024
62a2793
Fixes env var typo
CollectiveUnicorn Aug 2, 2024
86f0b4b
Adds script to seed the realtime instance
CollectiveUnicorn Aug 2, 2024
4d9bbd9
Moves script somewhere with permissions
CollectiveUnicorn Aug 2, 2024
39cc4d5
Moves script to values file
CollectiveUnicorn Aug 2, 2024
dca8c65
Updates url and var for realtime init container
CollectiveUnicorn Aug 2, 2024
c254ee3
Replace initContainer with sidecars
CollectiveUnicorn Aug 2, 2024
811cefb
Adds wait for realtime container
CollectiveUnicorn Aug 2, 2024
1ec9ad8
Replaces os-shell with busybox
CollectiveUnicorn Aug 2, 2024
2829b41
Replaces busybox container with a curl container
CollectiveUnicorn Aug 2, 2024
4a30a4b
Replaces nc wait with curl wait
CollectiveUnicorn Aug 2, 2024
ffa7ffa
Try to replace how the realtimme seed is happening
CollectiveUnicorn Aug 5, 2024
a8fe333
Merge branch 'main' into fix-supabase-realtime
CollectiveUnicorn Aug 5, 2024
3677383
Replaces job with inline curl call
CollectiveUnicorn Aug 5, 2024
395454c
Replaces wget commands with curl
CollectiveUnicorn Aug 5, 2024
f99eda0
Replaces invalid health endpoint on realtime
CollectiveUnicorn Aug 5, 2024
0327095
Moves the curl command to one line
CollectiveUnicorn Aug 5, 2024
18fccac
Updates versions of supabase-realtime
CollectiveUnicorn Aug 5, 2024
5776532
Sets the ENC_KEY to a default value of 16 chars
CollectiveUnicorn Aug 5, 2024
294ec62
Makes the sidecar sleep after a successful run to prevent crashbackloops
CollectiveUnicorn Aug 5, 2024
b7cb54c
Adds notify private alpha
CollectiveUnicorn Aug 7, 2024
27b96e3
Replaces DB_ENC_KEY with JWT_SECRET
CollectiveUnicorn Aug 7, 2024
a2932a4
Updates the JWT_SECRET to be correct
CollectiveUnicorn Aug 7, 2024
cc85394
Removes unnecessary quotes that interfere with SSL configs
CollectiveUnicorn Aug 7, 2024
a33a3ba
Replaces sidecar based realtime tenant initialization with init args
CollectiveUnicorn Aug 8, 2024
3882e15
Adds back necessary quotes
CollectiveUnicorn Aug 8, 2024
5296c66
Adds migration to update the freshly seeded db
CollectiveUnicorn Aug 8, 2024
673c07a
Randomly generates enc_secret instead of hard coding it
CollectiveUnicorn Aug 8, 2024
537239e
Replaces secret name to prevent deployment errors
CollectiveUnicorn Aug 8, 2024
92c314f
Creates _realtime schema and sets up deployment to use it
CollectiveUnicorn Aug 8, 2024
5b055e5
Set the search path back to public
CollectiveUnicorn Aug 8, 2024
c04adf6
Initialize _realtime table in after connect query
CollectiveUnicorn Aug 8, 2024
87e8a52
Replaces multiple queries with a single query
CollectiveUnicorn Aug 8, 2024
a5cbb4b
Updates the migration to represent the new location
CollectiveUnicorn Aug 8, 2024
bcc000d
Swaps out postgres image for one with wal2json
CollectiveUnicorn Aug 8, 2024
3cc1bc1
Moves back to older postgres image
CollectiveUnicorn Aug 8, 2024
c57facf
Switch to official supabase postgres image
CollectiveUnicorn Aug 8, 2024
1c083e8
Returns to using a base postgres image
CollectiveUnicorn Aug 8, 2024
11888cb
Updates the config to set the wal_level to logical
CollectiveUnicorn Aug 8, 2024
ce97caf
Merge branch 'main' into fix-supabase-realtime
CollectiveUnicorn Aug 8, 2024
b3a47b0
Fixes typo in manifests
CollectiveUnicorn Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/supabase/bitnami-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ realtime:
resourcesPreset: "none"
podLabels:
sidecar.istio.io/inject: "false"
extraEnvVars:
- name: APP_NAME
value: "supabase-realtime"
- name: DB_AFTER_CONNECT_QUERY
value: "DO $body$ BEGIN CREATE SCHEMA IF NOT EXISTS _realtime; ALTER SCHEMA _realtime OWNER TO postgres; SET search_path TO _realtime; END $body$;"
- name: DB_ENC_KEY
valueFrom:
secretKeyRef:
name: supabase-realtime-extra
key: dbEncKey
- name: DNS_NODES
value: "supabase-realtime"
args:
- -ec
- |
realtime eval Realtime.Release.migrate && realtime eval 'Realtime.Release.seeds(Realtime.Repo)' && realtime start

rest:
enabled: ###ZARF_VAR_ENABLE_REST###
Expand Down Expand Up @@ -107,7 +123,7 @@ volumePermissions:
resourcesPreset: "none"

psqlImage:
tag: 15.1.1-debian-12-r69
tag: 15.6.1-debian-12-r2

kong:
enabled: ###ZARF_VAR_ENABLE_KONG###
Expand Down Expand Up @@ -172,9 +188,11 @@ kong:
postgresql:
enabled: ###ZARF_VAR_ENABLE_POSTGRES###
image:
tag: 15.1.1-debian-12-r69
tag: 15.6.1-debian-12-r2
debug: true
primary:
extendedConfiguration: |
wal_level = logical
resourcesPreset: "none"
podLabels:
sidecar.istio.io/inject: "false"
Expand All @@ -184,4 +202,4 @@ postgresql:
## @param postgresql.postgresqlSharedPreloadLibraries Set the shared_preload_libraries parameter in postgresql.conf
## Setting an empty value in order to force the default extensions of supabase-postgres
##
postgresqlSharedPreloadLibraries: "pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, vector"
postgresqlSharedPreloadLibraries: "pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, vector"
18 changes: 18 additions & 0 deletions packages/supabase/chart/templates/supabase-realtime-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- $dbEncKey := randAlphaNum 16 }} # This needs to be exactly 16 characters
{{- $existingSecret := (lookup "v1" "Secret" .Release.Namespace "supabase-realtime-extra") }}
apiVersion: v1
kind: Secret
metadata:
name: supabase-realtime-extra
namespace: {{ .Release.Namespace }}
{{- if $existingSecret }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
type: Opaque
data:
{{- if $existingSecret }}
dbEncKey: {{ $existingSecret.data.dbEncKey }}
{{- else }}
dbEncKey: {{ $dbEncKey | b64enc | quote }}
{{- end }}
28 changes: 24 additions & 4 deletions packages/supabase/manifests/declarative-conf-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,31 @@ data:
- admin
- anon

- name: realtime-v1
_comment: "Realtime: /realtime/v1/* -> ws://supabase-realtime:80/socket/*"
url: http://supabase-realtime:80/socket
- name: realtime-v1-ws
_comment: "Realtime: /realtime/v1/* -> ws://supabase-realtime:80/socket/websocket/*"
url: http://supabase-realtime:80/socket/websocket
routes:
- name: realtime-v1-all
- name: realtime-v1-ws
strip_path: true
paths:
- /realtime/v1/websocket
plugins:
- name: cors
- name: key-auth
config:
hide_credentials: false
- name: acl
config:
hide_groups_header: true
allow:
- admin
- anon

- name: realtime-v1-api
_comment: "Realtime: /realtime/v1/* -> http://supabase-realtime:80/*"
url: http://supabase-realtime:80
routes:
- name: realtime-v1-api
strip_path: true
paths:
- /realtime/v1/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Disable the foreign key constraint
ALTER TABLE _realtime.extensions
DROP CONSTRAINT extensions_tenant_external_id_fkey;

-- Update the external_id and name for the realtime tenant
UPDATE _realtime.tenants
SET external_id = 'supabase-realtime',
name = 'supabase-realtime'
WHERE external_id = 'realtime-dev'
AND name = 'realtime-dev';

-- Update the tenant_external_id for the realtime extension
UPDATE _realtime.extensions
SET tenant_external_id = 'supabase-realtime'
WHERE tenant_external_id = 'realtime-dev';

-- Re-enable the foreign key constraint
ALTER TABLE _realtime.extensions
ADD CONSTRAINT extensions_tenant_external_id_fkey
FOREIGN KEY (tenant_external_id)
REFERENCES _realtime.tenants(external_id)
ON DELETE CASCADE;
26 changes: 13 additions & 13 deletions packages/supabase/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ components:
namespace: leapfrogai
url: oci://registry-1.docker.io/bitnamicharts/supabase
releaseName: supabase-bootstrap
version: 4.0.5
version: 5.3.3
valuesFiles:
- "bitnami-values.yaml"
- "bitnami-values-bootstrap.yaml"
Expand All @@ -81,21 +81,21 @@ components:
namespace: leapfrogai
url: oci://registry-1.docker.io/bitnamicharts/supabase
releaseName: supabase
version: 4.0.5
version: 5.3.3
valuesFiles:
- "bitnami-values.yaml"
images:
- docker.io/bitnami/gotrue:2.150.1-debian-12-r1
- docker.io/bitnami/jwt-cli:6.0.0-debian-12-r20
- docker.io/bitnami/kubectl:1.30.0-debian-12-r0
- docker.io/bitnami/os-shell:12-debian-12-r19
- docker.io/bitnami/postgrest:11.2.2-debian-12-r15
- docker.io/bitnami/supabase-postgres:15.1.1-debian-12-r69
- docker.io/bitnami/supabase-postgres-meta:0.80.0-debian-12-r3
- docker.io/bitnami/supabase-realtime:2.28.32-debian-12-r2
- docker.io/bitnami/supabase-storage:0.48.4-debian-12-r2
- docker.io/bitnami/supabase-studio:0.24.3-debian-12-r3
- docker.io/bitnami/kong:3.6.1-debian-12-r18
- docker.io/bitnami/gotrue:2.155.6-debian-12-r3
- docker.io/bitnami/jwt-cli:6.1.0-debian-12-r5
- docker.io/bitnami/kubectl:1.30.3-debian-12-r4
- docker.io/bitnami/os-shell:12-debian-12-r27
- docker.io/bitnami/postgrest:11.2.2-debian-12-r31
- docker.io/bitnami/supabase-postgres:15.6.1-debian-12-r2
- docker.io/bitnami/supabase-postgres-meta:0.83.2-debian-12-r3
- docker.io/bitnami/supabase-realtime:2.30.14-debian-12-r2
- docker.io/bitnami/supabase-storage:1.8.2-debian-12-r2
- docker.io/bitnami/supabase-studio:1.24.5-debian-12-r4
- docker.io/bitnami/kong:3.7.1-debian-12-r5
- name: supabase-post-process
description: "Perform necessary post processing here"
required: true
Expand Down