This is one of those things I didn't expect to be quite this involved and couldn't find a step-by-step guide for. I just want to allocate a disk out there in The Cloud and put something on it, right? The idea being that then I spin up a cluster and my fancy application server container startup script pulls that static data off the disk and performs whatever initialization is required. It doesn't sound especially complicated.
But as yet, there's no "upload some stuff" button in the Google Cloud Engine console, and gcloud compute scp
only works for VM instances. There's nothing sitting in front of a Persistent Disk that will just pull your data into it. So, you have to create one:
- Spin up a new VM instance in the Compute Engine screens. You'll need to be an
iam.serviceAccountUser
for the project. -
Once it's running, log in:
gcloud compute --project "my-project" ssh --zone "us-central1-b" "my-new-instance"
lsblk
shows devices as usual. Find yours. Now format it:sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdwhatever
Create a mountpoint and
sudo mount -o discard,defaults /dev/sdwhatever /mnt/my-mount-point
.Add your files, then clean up after yourself and
umount
the mountpoint.
Delete the instance from the VM Instances page. A GCE Persistent Disk can't be attached in read/write mode to more than one instance or container, also something to be mindful of if you're adding it to a deployment with multiple replicas.