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. From the gcloud CLI, run gcloud cloud-shell ssh . This will establish an interactive SSH session with Cloud Shell.
Click Activate Cloud Shell at the top of the Google Cloud console. A Cloud Shell session opens inside a new frame at the bottom of the Google Cloud console and displays a command-line prompt. It can take a few seconds for the session to be initialized.
Cloud Shell instances are provisioned on a per-user, per-session basis. The instance persists while your Cloud Shell session is active; after an hour of inactivity, your session terminates and its VM is discarded.
The access modes are: ReadWriteOnce. the volume can be mounted as read-write by a single node. ReadWriteOnce access mode still can allow multiple pods to access the volume when the pods are running on the same node. ReadOnlyMany.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With