Skip to content

Commit a04f85e

Browse files
authored
fix: update the state of helm chart to match self-hosted configuration of 2025
This PR addresses many accumulated issues and overlaps with quite a few separate PRs that were submitted previously.
2 parents 8626dcc + d03ceb6 commit a04f85e

26 files changed

+405
-239
lines changed

build/supabase-0.2.0.tgz

30.5 KB
Binary file not shown.

charts/supabase/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.3
18+
version: 0.2.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/supabase/templates/analytics/deployment.yaml

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,13 @@ spec:
4040
value: {{ .Values.analytics.environment.DB_HOST | quote }}
4141
{{- end }}
4242
- name: DB_USER
43-
valueFrom:
44-
secretKeyRef:
45-
{{- if .Values.secret.db.secretRef }}
46-
name: {{ .Values.secret.db.secretRef }}
47-
key: {{ .Values.secret.db.secretRefKey.username | default "username" }}
48-
{{- else }}
49-
name: {{ include "supabase.secret.db" . }}
50-
key: username
51-
{{- end }}
43+
value: $(DB_USERNAME)
5244
- name: DB_PORT
5345
value: {{ .Values.analytics.environment.DB_PORT | quote }}
5446
command: ["/bin/sh", "-c"]
5547
args:
5648
- |
57-
until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U $(DB_USER); do
49+
until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U postgres; do
5850
echo "Waiting for database to start..."
5951
sleep 2
6052
done
@@ -96,25 +88,25 @@ spec:
9688
name: {{ include "supabase.secret.db" . }}
9789
key: password_encoded
9890
{{- end }}
99-
- name: DB_DATABASE
91+
- name: LOGFLARE_PUBLIC_ACCESS_TOKEN
10092
valueFrom:
10193
secretKeyRef:
102-
{{- if .Values.secret.db.secretRef }}
103-
name: {{ .Values.secret.db.secretRef }}
104-
key: {{ .Values.secret.db.secretRefKey.database | default "database" }}
94+
{{- if .Values.secret.analytics.secretRef }}
95+
name: {{ .Values.secret.analytics.secretRef }}
96+
key: {{ .Values.secret.analytics.secretRefKey.publicAccessToken | default "apiKey" }}
10597
{{- else }}
106-
name: {{ include "supabase.secret.db" . }}
107-
key: database
98+
name: {{ include "supabase.secret.analytics" . }}
99+
key: publicAccessToken
108100
{{- end }}
109-
- name: LOGFLARE_API_KEY
101+
- name: LOGFLARE_PRIVATE_ACCESS_TOKEN
110102
valueFrom:
111103
secretKeyRef:
112104
{{- if .Values.secret.analytics.secretRef }}
113105
name: {{ .Values.secret.analytics.secretRef }}
114-
key: {{ .Values.secret.analytics.secretRefKey.apiKey | default "apiKey" }}
106+
key: {{ .Values.secret.analytics.secretRefKey.privateAccessToken | default "apiKey" }}
115107
{{- else }}
116108
name: {{ include "supabase.secret.analytics" . }}
117-
key: apiKey
109+
key: privateAccessToken
118110
{{- end }}
119111
{{- if .Values.analytics.bigQuery.enabled }}
120112
- name: GOOGLE_PROJECT_ID
@@ -124,10 +116,6 @@ spec:
124116
{{- else }}
125117
- name: POSTGRES_BACKEND_URL
126118
value: $(DB_DRIVER)://$(DB_USERNAME):$(DB_PASSWORD_ENC)@$(DB_HOSTNAME):$(DB_PORT)/$(DB_DATABASE)
127-
- name: POSTGRES_BACKEND_SCHEMA
128-
value: $(DB_SCHEMA)
129-
- name: LOGFLARE_FEATURE_FLAG_OVERRIDE
130-
value: $(FEATURE_FLAG_OVERRIDE)
131119
{{- end }}
132120
{{- with .Values.analytics.livenessProbe }}
133121
livenessProbe:
@@ -178,4 +166,4 @@ spec:
178166
tolerations:
179167
{{- toYaml . | nindent 8 }}
180168
{{- end }}
181-
{{- end }}
169+
{{- end }}

charts/supabase/templates/auth/deployment.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,12 @@ spec:
3939
{{- else }}
4040
value: {{ .Values.auth.environment.DB_HOST | quote }}
4141
{{- end }}
42-
- name: DB_USER
43-
valueFrom:
44-
secretKeyRef:
45-
{{- if .Values.secret.db.secretRef }}
46-
name: {{ .Values.secret.db.secretRef }}
47-
key: {{ .Values.secret.db.secretRefKey.username | default "username" }}
48-
{{- else }}
49-
name: {{ include "supabase.secret.db" . }}
50-
key: username
51-
{{- end }}
5242
- name: DB_PORT
5343
value: {{ .Values.auth.environment.DB_PORT | quote }}
5444
command: ["/bin/sh", "-c"]
5545
args:
5646
- |
57-
until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U $(DB_USER); do
47+
until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U postgres; do
5848
echo "Waiting for database to start..."
5949
sleep 2
6050
done
@@ -178,4 +168,4 @@ spec:
178168
tolerations:
179169
{{- toYaml . | nindent 8 }}
180170
{{- end }}
181-
{{- end }}
171+
{{- end }}

charts/supabase/templates/db/initdb.config.yaml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ data:
1010
\set jwt_secret `echo "$JWT_SECRET"`
1111
\set jwt_exp `echo "$JWT_EXP"`
1212
13-
ALTER DATABASE postgres SET "app.settings.jwt_secret" TO :jwt_secret;
14-
ALTER DATABASE postgres SET "app.settings.jwt_exp" TO :jwt_exp;
15-
99-logs.sql: |
13+
ALTER DATABASE postgres SET "app.settings.jwt_secret" TO :'jwt_secret';
14+
ALTER DATABASE postgres SET "app.settings.jwt_exp" TO :'jwt_exp';
15+
99-pooler.sql: |
1616
\set pguser `echo "$POSTGRES_USER"`
1717
18+
\c _supabase
19+
create schema if not exists _supavisor;
20+
alter schema _supavisor owner to :pguser;
21+
\c postgres
22+
99-logs.sql: |
23+
\set pguser `echo "$POSTGRES_USER"`
24+
\c _supabase
1825
create schema if not exists _analytics;
1926
alter schema _analytics owner to :pguser;
27+
\c postgres
2028
99-realtime.sql: |
2129
\set pguser `echo "$POSTGRES_USER"`
2230
@@ -31,6 +39,10 @@ data:
3139
ALTER USER supabase_auth_admin WITH PASSWORD :'pgpass';
3240
ALTER USER supabase_functions_admin WITH PASSWORD :'pgpass';
3341
ALTER USER supabase_storage_admin WITH PASSWORD :'pgpass';
42+
97-_supabase.sql: |
43+
\set pguser `echo "$POSTGRES_USER"`
44+
45+
CREATE DATABASE _supabase WITH OWNER :pguser;
3446
98-webhooks.sql: |
3547
BEGIN;
3648
-- Create pg_net extension
@@ -75,29 +87,29 @@ data:
7587
IF url IS NULL OR url = 'null' THEN
7688
RAISE EXCEPTION 'url argument is missing';
7789
END IF;
78-
90+
7991
IF method IS NULL OR method = 'null' THEN
8092
RAISE EXCEPTION 'method argument is missing';
8193
END IF;
82-
94+
8395
IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN
8496
headers = '{"Content-Type": "application/json"}'::jsonb;
8597
ELSE
8698
headers = TG_ARGV[2]::jsonb;
8799
END IF;
88-
100+
89101
IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN
90102
params = '{}'::jsonb;
91103
ELSE
92104
params = TG_ARGV[3]::jsonb;
93105
END IF;
94-
106+
95107
IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN
96108
timeout_ms = 1000;
97109
ELSE
98110
timeout_ms = TG_ARGV[4]::integer;
99111
END IF;
100-
112+
101113
CASE
102114
WHEN method = 'GET' THEN
103115
SELECT http_get INTO request_id FROM net.http_get(
@@ -114,7 +126,7 @@ data:
114126
'table', TG_TABLE_NAME,
115127
'schema', TG_TABLE_SCHEMA
116128
);
117-
129+
118130
SELECT http_post INTO request_id FROM net.http_post(
119131
url,
120132
payload,
@@ -125,12 +137,12 @@ data:
125137
ELSE
126138
RAISE EXCEPTION 'method argument % is invalid', method;
127139
END CASE;
128-
140+
129141
INSERT INTO supabase_functions.hooks
130142
(hook_table_id, hook_name, request_id)
131143
VALUES
132144
(TG_RELID, TG_NAME, request_id);
133-
145+
134146
RETURN NEW;
135147
END
136148
$function$;
@@ -240,4 +252,4 @@ data:
240252
REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC;
241253
GRANT EXECUTE ON FUNCTION supabase_functions.http_request() TO postgres, anon, authenticated, service_role;
242254
COMMIT;
243-
{{- end }}
255+
{{- end }}

charts/supabase/templates/db/migration.config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ metadata:
77
{{- include "supabase.labels" . | nindent 4 }}
88
data:
99
{{- toYaml .Values.db.config | nindent 2 }}
10-
{{- end }}
10+
{{- end }}

charts/supabase/templates/db/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ spec:
1414
name: http
1515
selector:
1616
{{- include "supabase.db.selectorLabels" . | nindent 4 }}
17-
{{- end }}
17+
{{- end }}

charts/supabase/templates/db/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ metadata:
1111
{{- toYaml . | nindent 4 }}
1212
{{- end }}
1313
{{- end }}
14-
{{- end }}
14+
{{- end }}

charts/supabase/templates/db/deployment.yaml renamed to charts/supabase/templates/db/statefulset.yaml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- if .Values.db.enabled -}}
22
apiVersion: apps/v1
3-
kind: Deployment
3+
kind: StatefulSet
44
metadata:
55
name: {{ include "supabase.db.fullname" . }}
66
labels:
@@ -39,8 +39,12 @@ spec:
3939
cp -r /docker-entrypoint-initdb.d/* /initdb.d/
4040
cp /custom-init-scripts/98-webhooks.sql /initdb.d/init-scripts/
4141
cp /custom-init-scripts/99-roles.sql /initdb.d/init-scripts/
42+
cp /custom-init-scripts/99-jwt.sql /initdb.d/init-scripts/
43+
4244
cp /custom-init-scripts/99-logs.sql /initdb.d/migrations/
4345
cp /custom-init-scripts/99-realtime.sql /initdb.d/migrations/
46+
cp /custom-init-scripts/97-_supabase.sql /initdb.d/migrations/
47+
cp /custom-init-scripts/99-pooler.sql /initdb.d/migrations/
4448
4549
echo "Copying user-defined migration scripts..."
4650
cp /custom-migrations/* /initdb.d/migrations/ || echo "Skip migrations"
@@ -58,21 +62,15 @@ spec:
5862
{{- toYaml .Values.db.securityContext | nindent 12 }}
5963
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag | default .Chart.AppVersion }}"
6064
imagePullPolicy: {{ .Values.db.image.pullPolicy }}
65+
lifecycle:
66+
preStop:
67+
exec:
68+
command: ["/bin/sh", "-c", "pg_ctl -D /var/lib/postgres/data -w -t 60 -m fast stop"]
6169
env:
6270
{{- range $key, $value := .Values.db.environment }}
6371
- name: {{ $key }}
6472
value: {{ $value | quote }}
6573
{{- end }}
66-
- name: POSTGRES_USER
67-
valueFrom:
68-
secretKeyRef:
69-
{{- if .Values.secret.db.secretRef }}
70-
name: {{ .Values.secret.db.secretRef }}
71-
key: {{ .Values.secret.db.secretRefKey.username | default "username" }}
72-
{{- else }}
73-
name: {{ include "supabase.secret.db" . }}
74-
key: username
75-
{{- end }}
7674
- name: PGPASSWORD
7775
valueFrom:
7876
secretKeyRef:
@@ -113,6 +111,16 @@ spec:
113111
name: {{ include "supabase.secret.db" . }}
114112
key: database
115113
{{- end }}
114+
- name: JWT_SECRET
115+
valueFrom:
116+
secretKeyRef:
117+
{{- if .Values.secret.jwt.secretRef }}
118+
name: {{ .Values.secret.jwt.secretRef }}
119+
key: {{ .Values.secret.jwt.secretRefKey.secret | default "database" }}
120+
{{- else }}
121+
name: {{ include "supabase.secret.jwt" . }}
122+
key: secret
123+
{{- end }}
116124
{{- with .Values.db.livenessProbe }}
117125
livenessProbe:
118126
{{- toYaml . | nindent 12 }}
@@ -123,7 +131,7 @@ spec:
123131
{{- end }}
124132
ports:
125133
- name: http
126-
containerPort: 9999
134+
containerPort: 5432
127135
protocol: TCP
128136
volumeMounts:
129137
- mountPath: /docker-entrypoint-initdb.d
@@ -170,4 +178,4 @@ spec:
170178
tolerations:
171179
{{- toYaml . | nindent 8 }}
172180
{{- end }}
173-
{{- end }}
181+
{{- end }}

charts/supabase/templates/functions/deployment.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ spec:
3838
{{- toYaml .Values.functions.securityContext | nindent 12 }}
3939
image: "{{ .Values.functions.image.repository }}:{{ .Values.functions.image.tag | default .Chart.AppVersion }}"
4040
imagePullPolicy: {{ .Values.functions.image.pullPolicy }}
41+
{{- if .Values.functions.envFrom }}
42+
envFrom:
43+
{{- toYaml .Values.functions.envFrom | nindent 12 }}
44+
{{- end }}
4145
env:
4246
{{- range $key, $value := .Values.functions.environment }}
4347
- name: {{ $key }}
4448
value: {{ $value | quote }}
4549
{{- end }}
50+
51+
{{- if .Values.kong.enabled }}
52+
- name: SUPABASE_URL
53+
value: http://{{ include "supabase.kong.fullname" . }}:{{ .Values.kong.service.port }}
54+
{{- end }}
55+
4656
- name: DB_HOSTNAME
4757
{{- if .Values.db.enabled }}
4858
value: {{ include "supabase.db.fullname" . }}
@@ -109,7 +119,7 @@ spec:
109119
name: {{ include "supabase.secret.jwt" . }}
110120
key: serviceKey
111121
{{- end }}
112-
- name: POSTGRES_BACKEND_URL
122+
- name: SUPABASE_DB_URL
113123
value: $(DB_DRIVER)://$(DB_USERNAME):$(DB_PASSWORD_ENC)@$(DB_HOSTNAME):$(DB_PORT)/$(DB_DATABASE)?search_path=auth&sslmode=$(DB_SSL)
114124
{{- with .Values.functions.livenessProbe }}
115125
livenessProbe:
@@ -148,4 +158,4 @@ spec:
148158
tolerations:
149159
{{- toYaml . | nindent 8 }}
150160
{{- end }}
151-
{{- end }}
161+
{{- end }}

0 commit comments

Comments
 (0)