How can I put files into a persistent disk before starting up a VM that relies on data in the disk?

567 views Asked by At

I have a VM that requires access to some credential files. I'd like these credential files to exist within a standard persistent disk that is mounted to the VM. These files need to exist when the container in the VM starts. If they do not, the container will exit and restart. Since it will continually exit and restart, there is no opportunity to hop into the VM, enter the container, and place the files.

So I'd like to know if there's a way to access a standard persistent disk from outside of a compute engine VM, so that I can place files in it, before it is mounted to the VM container on startup.

Is there any way to do this?

1

There are 1 answers

0
Pejvak On

You may consider GCS FUSE [1] which allow you to mount Cloud Storage buckets as file systems on Linux or macOS systems.

As a second workaround please check using persistent disks with multiple readers [2] if the credentials only need to be placed in the disk once a GCS bucket would be better in the long term.

[1] https://cloud.google.com/storage/docs/gcs-fuse [2] https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks