charts icon indicating copy to clipboard operation
charts copied to clipboard

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

Open lautaro79 opened this issue 9 months ago • 17 comments

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)

lautaro79 avatar Apr 29 '24 14:04 lautaro79

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

carrodher avatar May 01 '24 08:05 carrodher

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

lautaro79 avatar May 02 '24 13:05 lautaro79

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.

dennismuench avatar May 04 '24 11:05 dennismuench

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

alemorcuq avatar May 10 '24 09:05 alemorcuq

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

gpgkd906 avatar May 14 '24 06:05 gpgkd906

hi @alemorcuq

any updates on this issue?

thanks

lautaro79 avatar May 21 '24 17:05 lautaro79

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] avatar Jun 06 '24 01:06 github-actions[bot]

hi @carrodher @alemorcuq

any updates on this issue?

thanks

lautaro79 avatar Jun 06 '24 12:06 lautaro79

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.

github-actions[bot] avatar Jun 12 '24 01:06 github-actions[bot]

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

BeechyM avatar Jun 27 '24 14:06 BeechyM

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] avatar Jul 14 '24 01:07 github-actions[bot]

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.

github-actions[bot] avatar Jul 20 '24 01:07 github-actions[bot]

Is there any update on this?

BeechyM avatar Jul 22 '24 07:07 BeechyM

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?

Gageperrin avatar Jul 25 '24 13:07 Gageperrin

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

BeechyM avatar Jul 29 '24 05:07 BeechyM

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:

  • Activate several extensions: code
  • Run some database migrations: code (upstream)

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

andresbono avatar Aug 08 '24 11:08 andresbono

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] avatar Aug 24 '24 01:08 github-actions[bot]

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.

github-actions[bot] avatar Aug 29 '24 01:08 github-actions[bot]