supabase-kubernetes
supabase-kubernetes copied to clipboard
Improve Edge Function Documentation
Improve documentation
Can we provide an example of deploying an edge function?
Link
Add a link to the page which needs improvement (if relevant)
Describe the problem
There is no documentation or example on creating an edge function in this chart. While I'd love to supabase functions deploy the client doesn't support connecting to a local improvement.
Describe the improvement
- Define how to take an edge function and place it to this chart
- Steps to update the config files
- Gotcha's etc.
Following up on this issue:
Found that the yaml for the kong-config isn't properly taking the deployment service name.
Here is the change that fixed it:
Moreover, here is how I configured a map to the functions with a persistent storage class:
values.example.yaml
functions:
enabled: true
nodeSelector:
nodeName: "ai-server-1"
image:
tag: v1.41.2
environment:
DB_PORT: 5433
VERIFY_JWT: false
service:
type: ClusterIP
port: 9002
volumeMounts:
- name: myfunctions
mountPath: /home/deno/functions/custom/
volumes:
- name: myfunctions
then in templates/functions/functions.config.yaml
# LN:76
const servicePath = `/home/deno/functions/custom/${service_name}`
Finally, to get the functions in there, I deploy it with a kubectl copy:
#!/bin/bash
functionspod=`kubectl get pods -l app.kubernetes.io/name=supabase-functions --output=jsonpath={.items..metadata.name}`
kubectl cp ./supabase/functions/* ${functionspod}:/home/deno/functions/custom/
now I get to the hook as expected and can continue developing
Finally, to get the functions in there, I deploy it with a kubectl copy:
#!/bin/bash functionspod=`kubectl get pods -l app.kubernetes.io/name=supabase-functions --output=jsonpath={.items..metadata.name}` kubectl cp ./supabase/functions/* ${functionspod}:/home/deno/functions/custom/
But this needs to be run for each pod in which case it would not work with autoscaling, right? Is there a recommended way to persist the functions and update them every time a new version is deployed using GitHub Actions?
One way would be to move all functions into a config map (like this) and mount that map as is done with the main function. But I don't think that's what config maps are meant for and it also does not work if all edge functions exceed 1MB.
I am currently looking into Persistent Volumes, but I am very inexperienced with Kubernetes. Any pointers from someone running this in production would be helpful.
Finally, to get the functions in there, I deploy it with a kubectl copy:
#!/bin/bash functionspod=`kubectl get pods -l app.kubernetes.io/name=supabase-functions --output=jsonpath={.items..metadata.name}` kubectl cp ./supabase/functions/* ${functionspod}:/home/deno/functions/custom/But this needs to be run for each pod in which case it would not work with autoscaling, right? Is there a recommended way to persist the functions and update them every time a new version is deployed using GitHub Actions?
One way would be to move all functions into a config map (like this) and mount that map as is done with the main function. But I don't think that's what config maps are meant for and it also does not work if all edge functions exceed 1MB.
I am currently looking into Persistent Volumes, but I am very inexperienced with Kubernetes. Any pointers from someone running this in production would be helpful.
As you're inexperienced in kubernetes, check out storage providers for k8s. Many storage providers allow you to configure multi-node access to the same storage. I use an NFS mount for this function which makes it available to all deno pods that spin up. Just make sure that your functions don't do anything filesystem dependent or you can conflict when the pods scale.