Created
September 22, 2021 18:05
-
-
Save doubtingben/0984058d959f019c5def4373285b97c8 to your computer and use it in GitHub Desktop.
GKE PVC to VM disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NAMESPACE=mainnet-replica-0-4-13 | |
kubectl scale sts l2geth-replica --replicas=0 -n $NAMESPACE | |
PV=$(kubectl get pvc -n $NAMESPACE l2geth-replica-data -o jsonpath='{.spec.volumeName}') | |
GCLOUD_DISK=$(kubectl get pv $PV -o jsonpath='{.spec.gcePersistentDisk.pdName}') | |
SLUG=$NAMESPACE-$(date +%s) | |
gcloud compute disks snapshot $GCLOUD_DISK --snapshot-names=$SLUG --zone=us-central1-c | |
kubectl scale sts l2geth-replica --replicas=1 -n $NAMESPACE | |
gcloud compute disks create $SLUG --source-snapshot=$SLUG --type=pd-ssd --size=200 --zone us-central1-c | |
gcloud compute instances create \ | |
$SLUG-vm \ | |
--machine-type=n2-standard-4 \ | |
--zone=us-central1-c \ | |
--create-disk=size=2TB,type=pd-ssd,device-name=geth-root \ | |
--image-family=ubuntu-2004-lts \ | |
--image-project=ubuntu-os-cloud \ | |
--disk=name=$SLUG,device-name=geth-snapshot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment