Shell access to Persistent Volume in Google Cloud

3/31/2017

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?

-- elif
google-cloud-platform
google-compute-engine
kubernetes

2 Answers

3/31/2017

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

-- Ryank
Source: StackOverflow

3/31/2017

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.

-- mhouglum
Source: StackOverflow