bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.95k stars 9.18k forks source link

[bitnami/supabase] Auth pod failing in self-hosted Supabase in Kubernetes with external DB #25452

Closed lautaro79 closed 1 month ago

lautaro79 commented 5 months ago

Name and Version

bitnami/supabase 4.0.3

What architecture are you using?

None

What steps will reproduce the bug?

Execute this command:

helm upgrade --install supabase bitnami/supabase --version 4.0.3 -n supabase --values=./values.example.yaml

Are you using any custom parameters or values?

Where the file values.example.yaml contains:

studio:
  ingress:
    path: /
    enabled: true
    hostname: 'localhost'
    ingressClassName: nginx

postgresql:
  enabled: false
externalDatabase:
  host: 'my.external.db.host'
  port: '5432'
  user: 'supabase_admin'
  database: 'supabase'
  password: 'mysecretpassword'
  existingSecret: 'supabase-externaldb'
  existingSecretPasswordKey: db-password

What is the expected behavior?

All pods running correctly and connected to the configured External DB

What do you see instead?

Auth pod fails to start with the following error log:

{"level":"info","msg":"Go runtime metrics collection started","time":"2024-04-29T13:17:17Z"}
{"args":[".spdx-gotrue.spdx"],"component":"pop","level":"warning","msg":"ignoring file %s because it does not match the migration file pattern","time":"2024-04-29T13:17:17Z"}
{"args":["auth"],"component":"pop","level":"warning","msg":"ignoring file %s because it does not match the migration file pattern","time":"2024-04-29T13:17:17Z"}
{"args":["gotrue"],"component":"pop","level":"warning","msg":"ignoring file %s because it does not match the migration file pattern","time":"2024-04-29T13:17:17Z"}
{"args":["gotrue-2.149.0.txt"],"component":"pop","level":"warning","msg":"ignoring file %s because it does not match the migration file pattern","time":"2024-04-29T13:17:17Z"}
{"args":[0.018388729],"component":"pop","level":"info","msg":"%.4f seconds","time":"2024-04-29T13:17:17Z"}
{"level":"fatal","msg":"running db migrations: Migrator: problem creating schema migrations: could not execute CREATE TABLE \"schema_migrations\" (\n\"version\" VARCHAR (14) NOT NULL,\nPRIMARY KEY(\"version\")\n);\nCREATE UNIQUE INDEX \"schema_migrations_version_idx\" ON \"schema_migrations\" (version);: ERROR: no schema has been selected to create in (SQLSTATE 3F000)","time":"2024-04-29T13:17:17Z"}

Additional information

problem creating schema migrations: could not execute CREATE TABLE \"schema_migrations\"

no schema has been selected to create in (SQLSTATE 3F000)

carrodher commented 5 months ago

Could you provide more details about the external database you're using? For reference, the bundled database is PostgreSQL version 16.2.0

lautaro79 commented 5 months ago

hi @carrodher

I used this Postges image to test it: postgres:16.2

You can run this command to start it:

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -e POSTGRES_USER=supabase_admin -e POSTGRES_DB=supabase -d postgres:16.2

dennismuench commented 5 months ago

I am using the same configuration, same error no schema has been selected to create in (SQLSTATE 3F000). External DB with admin user. All pods can connect - the initial migration script seems to fail. I am using a managed PostgreSQL 15 database.

alemorcuq commented 5 months ago

👋 I've successfully reproduced the issue and I'm looking into it.

gpgkd906 commented 5 months ago

same configuration, same error no schema has been selected to create in (SQLSTATE 3F000), with PostgreSQL 16.3.0 as External DB.

lautaro79 commented 5 months ago

hi @alemorcuq

any updates on this issue?

thanks

github-actions[bot] commented 4 months ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

lautaro79 commented 4 months ago

hi @carrodher @alemorcuq

any updates on this issue?

thanks

github-actions[bot] commented 4 months ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

BeechyM commented 3 months ago

hi @carrodher @alemorcuq I'm currently experiencing the same issue. Is there any fix for this?

github-actions[bot] commented 3 months ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 3 months ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

BeechyM commented 3 months ago

Is there any update on this?

Gageperrin commented 2 months ago

Our team is considering migrating to the Bitnami Supabase Helm chart, but this seems like a critical issue that has been open for nearly 90 days without responsive communication from the Bitnami team. This raises concerns about how well-maintained this chart is.

@BeechyM were you able to find a workaround for the auth pod, or is this an ongoing blocker?

BeechyM commented 2 months ago

Our team is considering migrating to the Bitnami Supabase Helm chart, but this seems like a critical issue that has been open for nearly 90 days without responsive communication from the Bitnami team. This raises concerns about how well-maintained this chart is.

@BeechyM were you able to find a workaround for the auth pod, or is this an ongoing blocker?

We haven't found a solution yet, do use this Helm Chart with en external Database

andresbono commented 2 months ago

I can reproduce the issue in the following environment:

$ kind create cluster
$ helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --version 15.5.20 --set auth.username=supabase_admin,auth.password=mysecretpassword,auth.database=supabase
$ cat <<EOF >/tmp/values.example.yaml
postgresql:
  enabled: false
externalDatabase:
  host: postgresql.default.svc.cluster.local
  port: 5432
  user: supabase_admin
  database: supabase
  password: mysecretpassword
EOF
$ helm install supabase oci://registry-1.docker.io/bitnamicharts/supabase --version 5.3.3 --values=/tmp/values.example.yaml
$ kubectl logs deployment/supabase-auth -c gotrue | grep fatal
{"level":"fatal","msg":"running db migrations: Migrator: problem creating schema migrations: could not execute CREATE TABLE \"schema_migrations\" (\n\"version\" VARCHAR (14) NOT NULL,\nPRIMARY KEY(\"version\")\n);\nCREATE UNIQUE INDEX \"schema_migrations_version_idx\" ON \"schema_migrations\" (version);: ERROR: no schema has been selected to create in (SQLSTATE 3F000)","time":"2024-08-08T09:11:56Z"}

The problem here is that supabase is not expected to connect to a bare PostgreSQL database. Instead it has some requirements. Mainly (please, do not take this as an exhaustive list), those are:

Those migrations lead to have some hardcoded database configurations, as commented in the chart templates:

https://github.com/bitnami/charts/blob/95148a9ae1363f9da6415b64085aadfd8add1413/bitnami/supabase/templates/_helpers.tpl#L461-L464

https://github.com/bitnami/charts/blob/95148a9ae1363f9da6415b64085aadfd8add1413/bitnami/supabase/templates/_helpers.tpl#L475-L476

If you wanted to run PostgreSQL externally, you would need to meet those requirements, or use the bitnami/supabase-postgres container image that bundles all the required extensions and migration scripts (that is what it is done by this chart if postgresql.enabled=true)

$ kind create cluster
$ cat <<EOF >/tmp/values.postgresql.yaml
image:
  repository: bitnami/supabase-postgres
  tag: 15.6.1-debian-12-r2
postgresqlSharedPreloadLibraries: "pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain"
auth:
  postgresPassword: mysecretpassword
EOF
$ helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --version 15.5.20 --values /tmp/values.postgresql.yaml
$ cat <<EOF >/tmp/values.supabase.yaml
postgresql:
  enabled: false
externalDatabase:
  host: postgresql.default.svc.cluster.local
  port: 5432
  user: supabase_admin
  database: postgres # hardcoded
  password: mysecretpassword # hardcoded
EOF
$ helm install supabase oci://registry-1.docker.io/bitnamicharts/supabase --version 5.3.3 --values /tmp/values.supabase.yaml
github-actions[bot] commented 1 month ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 1 month ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.