0

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?

cilphex
  • 6,006
  • 6
  • 34
  • 44
  • Only if you attach the disk to a different VM temporarily. – Hitobat Aug 31 '20 at 20:48
  • 1
    Is storing credentials on a disk the right approach? Look at Google Secrets Manager or KMS to store secrets and pull them down when your container starts. Modify your app to read them or write a script that reads them. Google Cloud Storage is a better choice then a VM disk. – John Hanley Aug 31 '20 at 20:57
  • @JohnHanley I am looking for a solution that is compatible with Docker. I ended up putting the values in env vars, but it would still be able to write to a disk before mounting it to an active VM. – cilphex Sep 01 '20 at 01:35

1 Answers1

0

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

Pejvak
  • 150
  • 7