简体   繁体   中英

Shell access to Persistent Volume in Google Cloud

I would like to get shell access to the Persistent Volume I created on the Google Cloud Platform.

I tried using Google Cloud Shell for this. But to be able to do that I need to attach the Persistent Volume through the gcloud commands, and the command requires the instance name. But I don't see the instance name of the Google Cloud Shell when I list the instance names (in gcloud).

Is it possible to get shell access over Google Cloud Shell to the persistent disks? If not how can I get access to the Persistent Volume that I created?

Yes, all disks need to be attached to an instance to allow access to them - you will need to create a compute instance and mount the persistent disk with gcloud compute instances attach-disk [INSTANCE_NAME] --disk [DISK_NAME] .

Once you create the new instance the instance name will become visible to you for usage by running gcloud compute instances list

You will then be able to access the disk by ssh'ing into the instance and mounting it.

The following will help with mounting:

https://cloud.google.com/compute/docs/disks/add-persistent-disk

You don't see the Cloud Shell's instance name in your list of VMs because it isn't owned by your project (and thus, to answer your question, you won't have permission to attach your persistent disks to it). You can verify this by querying the "/zone" endpoint of the Cloud Shell's metadata server, via curl "http://metadata.google.internal/computeMetadata/v1/instance/zone" as described in the GCE docs .

As Ryank mentioned, you'd need to attach the disk to an instance owned by your project, then SSH into it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM