openfaas / faas-netes

Serverless Functions For Kubernetes
https://www.openfaas.com
MIT License
2.12k stars 473 forks source link

[Question] Where does OpenFaaS store the function metadata? #880

Open ctwkongmu opened 2 years ago

ctwkongmu commented 2 years ago

Not sure if this is the right place to ask this question. I'm quite new to OpenFaaS and I could find any document about how OpenFaaS stores function metadata, like function name, image location and so on. I'm also a little concerned about that if/how that information is persisted in OpenFaaS on kubernetes, and if I restart the cluster how should I make sure that those functions that have been deployed once will be loaded into the restarted openfaas cluster.

Thanks in advance!

LucasRoesler commented 2 years ago

faas-netes uses a combination of annotations and labels on Services and Deployments, as well as CRDs to store th metadata. This m ans all of the metadata, such as name, is simply stored in the cluster itself and shares the same persistence as your k8s cluster.

ctwkongmu commented 2 years ago

faas-netes uses a combination of annotations and labels on Services and Deployments, as well as CRDs to store th metadata. This m ans all of the metadata, such as name, is simply stored in the cluster itself and shares the same persistence as your k8s cluster.

@LucasRoesler Thanks for quick response. Is there any reference or guidelines about how to make function persistent on k8s? Like which path/file should I mount to make sure that the function will still be loaded after I tear down the openfaas k8s cluster and restart it. I did try helm delete and helm install combo and found the function I previously loaded were gone after the restart. Is there a best practice regarding making functions persistent?

Thanks in advance!

LucasRoesler commented 2 years ago

What exactly are you doing when you say "tear down the openfaas k8s cluster" are you deleting namespaces? Helm delete should only remove the openfaas components but leave the functions alone.

Unless you delete the function namespace, then it will delete all objects in those namespaces. This is just a feature of k8s.

Regarding function persistence, the functions are just labeled objects in the k8s cluster. So the best practice for persistence will be the same as persistence for any object in the k8s cluster and will depend specifically on how the k8s cluster is constructed

LucasRoesler commented 2 years ago

@ctwkongmu anything else we can clarify? If not I will close the issue.