Cheat Sheet
Google Cloud Platform tips and tricks.
echo "export CLOUDSDK_PYTHON=$(which python3)" >> ~/.zshrc
source ~/.zshrc
./install.sh
gcloud components install COMPONENT_ID
gcloud components remove COMPONENT_ID
gcloud config set project my-project
You may also set the environment variable
CLOUDSDK_CORE_PROJECT
.gcloud config set compute/region NAME
gcloud config set compute/zone NAME
CLOUDSDK_COMPUTE_REGION=us-central1
CLOUDSDK_COMPUTE_ZONE=us-central1-a
CLOUDSDK_CORE_PROJECT=my-project-123456
CLOUDSDK_CONTAINER_CLUSTER=cluster-1
gcloud config list --format 'value(core.project)'
gcloud config configurations list
gcloud compute --project "proj-id-253611" ssh --zone us-central1-a instance-1
Delete VM
# Make sure you are using the correct account
gcloud config list
# Display instance info
gcloud compute instances describe instance-1 --zone=us-central1-a --project=proj-id-253611gcloud compute instances describe instance-1 --zone=us-central1-a --project=proj-id-253611
# Delete instanace and ALL DISKS
gcloud compute instances delete instance-1 --zone=us-central1-a --project=proj-id-253611 --delete-disks=all
gcloud container clusters get-credentials cluster-1 --zone us-central1-c --project proj-id-253611
Deploy
git clone \
https://github.com/GoogleCloudPlatform/kubernetes-engine-samples
cd \
kubernetes-engine-samples/hello-app
docker build -t \
gcr.io/united-blend-253611/hello-app:v1 \
$PWD
gcloud docker -- push \
gcr.io/united-blend-253611/hello-app:v1
kubectl create deployment \
hello-app \
--image=gcr.io/united-blend-253611/hello-app:v1
kubectl expose deployment \
hello-app \
--type="LoadBalancer" --port \
8080
kubectl get service hello-app \
--watch
# Create SSH tunnel
gcloud compute ssh your-instance-name --project=your-project-name -- -NL 9022:127.0.0.1:22
# Mount remote folder locally
sshfs -odebug,sshfs_debug,loglevel=debug,ServerAliveInterval=30,IdentityFile=~/.ssh/google_compute_engine [email protected]:/remote/folder/path /local/folder/path -p 9022
# Mount local folder remotelly
sshfs -odebug,sshfs_debug,loglevel=debug,ServerAliveInterval=30,IdentityFile=~/.ssh/google_compute_engine /local/folder/path [email protected]:/remote/folder/path -p 9022
rsync
# Openn SSH tunnel
gcloud compute ssh your-instance --project=your-project -- -NL 9022:127.0.0.1:22
# Rsync from local to remote
rsync --progress --checksum -a -e "ssh -p 9022 -o IdentityFile=~/.ssh/google_compute_engine" /local/path [email protected]:/remote/path/
Last modified 2yr ago