Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 218
elif Avatar asked Mar 31 '17 07:03

elif


People also ask

Can you ssh into Google Cloud Shell?

Yes. From the gcloud CLI, run gcloud cloud-shell ssh . This will establish an interactive SSH session with Cloud Shell.

How do I access Google 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.

Is Google Cloud Shell persistent?

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.

What is access modes in persistent volume?

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.


2 Answers

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.

like image 39
mhouglum Avatar answered Oct 07 '22 13:10

mhouglum


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

like image 114
Ryank Avatar answered Oct 07 '22 13:10

Ryank