supabase-community / supabase-kubernetes

Helm 3 charts to deploy a Supabase on Kubernetes
Apache License 2.0
444 stars 118 forks source link

supabase studio hanging #21

Open zabealbe opened 2 years ago

zabealbe commented 2 years ago

Using the default configuration supabase studio hangs on this page

A hint can be found looking at the browser's dev console

This is a issue due to a wrong (or probably just outdated) env key value, under studio.environment in values.yml file

SUPABASE_URL should be renamed to SUPABASE_REST_URL

zabealbe commented 2 years ago

Found out to be another symptom of issue #9

fghimis commented 2 years ago

@zabealbe Take a look at the environment and service values from the values.yaml file here.

My main problem was CORS (you can see that in your image too). To fix that I used the following ingress annotations (I use ingress-nginx): kong: ... ingress: annotations: nginx.ingress.kubernetes.io/cors-allow-headers: apikey,authorization,content-type,x-request-id nginx.ingress.kubernetes.io/cors-allow-origin: "*" nginx.ingress.kubernetes.io/enable-cors: "true"

I used an ingress for kong and studio. That means, I modified the following environment variables:

I don't know if the last issue from #9 happens here too. My problem with the db ("FATAL: data directory "/var/lib/postgresql/data"") was solved by setting the correct ownership and permissions for the given directory in the lifecycle.postStart.exec.command:

Also, for some reason the default command from the docker-compose file didn't work. For me the following command worked:

I used the images from the docker-compose and the environment variables from values.yaml.

zabealbe commented 2 years ago

@fghimis kong is already configured to set the Access-Control-Allow-Origin header, however with the default chart configuration it allows for any origin which is not ideal in a production environment

In my picture you see the cors error simply because the request never reached kong in the first place.

fghimis commented 2 years ago

@zabealbe From the docker-compose file you can see that studio runs by default on port 3000 and kong runs on 8000. You went to the studio URL, inspected the page, and you can see that studio does a request for localhost:8000.

Since you probably are running two deployments (one studio, one kong) you have two different pods with two different IPs. studio can't access kong at localhost:8000. Enter the studio container with kubectl exec -it -n <namespace> pod/studio -- bash and check /usr/src/app/.env (or checks the studio logs). If that file contains SUPABASE_URL=localhost:8000 it means that studio doesn't pick up the env variables.