3

I have a Google Firebase app with a Cloud Functions back-end. I'm using the node.js 10 runtime which is Ubuntu 18.04. Users can upload files to Google Cloud Storage, and that triggers a GCF function.

What I'd like that function to do is copy that file to Google Cloud Filestore (that's File with an L), Google's new NFS-mountable file server. They say the usual way to do that is from the command line with gsutil rsync or gcloud compute scp.

My question is: are either or both of those commands available on GCF nodes? Or is there another way? (It would be awesome if I could just mount the Filestore share on the GCF instance, but I'm guessing that's nontrivial.)

GaryO
  • 5,873
  • 1
  • 36
  • 61

2 Answers2

2

Using NFS based storage is not a good idea in this environment. NFS works by providing a mountable file system, something that will not work in Cloud Functions environment as the file system is read only with the exception of /tmp folder.

You should consider using cloud native storage systems like GCS for which the Application Default Credentials are already setup. See the list of supported services here.

Kunal Deo
  • 2,248
  • 2
  • 18
  • 27
  • OK, so my user uploads a (large) file from the front end. My function puts that in GCS temporarily, that's easy. But I still don't see how to get it from GCS to Filestore so my cloud 3d renderer can access it (that'll be running on CE VMs). And vice versa, when the render is done, how do I get it out of Filestore back to the front end? – GaryO Nov 16 '19 at 11:59
  • Filestore doesn't have a rest API for files. You have to mount it to use it. I would recommend creating a separate service on a GCE VM that is responsible for moving file in and out from Filestore to GCS. – Kunal Deo Nov 16 '19 at 12:18
  • Well, it's not quite true that you have to mount it; the docs say you can use the command-line tools I mentioned above. But I can see that getting those installed on the GCF instance, with the proper credentials, is going to be a problem. Sigh... Filestore looks so useful, until it's not. – GaryO Nov 16 '19 at 14:15
  • I think you are referring to the doc [here](https://cloud.google.com/filestore/docs/copying-data). The command mentioned here is `gsutil rsync gs://[BUCKET] [MOUNT_DIRECTORY]`. – Kunal Deo Nov 16 '19 at 15:33
  • Filestore is a NFS file system designed for use cases where you wanted network mounted file system. Limitations and benefits are derived from how NFS works. – Kunal Deo Nov 16 '19 at 15:35
  • Sure, I've used NFS for about 30 years. I'm just hoping there's a way to either mount that FS on the GCF instance (which there apparently isn't) or a Javascript/web-api way to do the equivalent to the `gsutil rsync` -- which there apparently isn't either. And I don't think the `gsutil` command exists on the GCF instances. – GaryO Nov 16 '19 at 16:51
1

According to the official documentation Cloud Filestore documentation

Use Cloud Filestore to create fully managed NFS file servers on Google Cloud Platform (GCP) for use with applications running on Compute Engine virtual machines (VMs) instances or Google Kubernetes Engine clusters.

You can not mount the Filestore on GCF.

Also, you can not execute gsutil or gcloud commands from a Google cloud function Writing Cloud Functions.

Google Cloud Functions can be written in Node.js, Python, and Go, and are executed in language-specific runtimes

marian.vladoi
  • 7,663
  • 1
  • 15
  • 29