LoginSignup
1
1

More than 5 years have passed since last update.

gcloud note

Last updated at Posted at 2016-07-10

install

https://developers.google.com/cloud/sdk/
and PATH, autocompl

config

config configurations?

≒ AWS's Profile

switch configurations

gcloud config configurations list
gcloud config configurations activate [configuration_name]

create configuration

gcloud config configurations create hoge 

all comands

auth

$ gcloud config set account <google.account>
$ gcloud auth login
$ gcloud auth application-default login

ADC?

Application Default Credentials.

WARNING: gcloud auth login no longer writes application default credentials.
If you need to use ADC, see:
$ gcloud auth application-default --help

https://stackoverflow.com/questions/41215667/google-cloud-sql-proxy-couldnt-find-default-credentials
https://github.com/StanfordBioinformatics/loom/issues/248

Change project

$ gcloud config set project <project-id>

Access Token

$ gcloud auth print-access-token

Create snapshot

$ gcloud compute disks snapshot fuji-devel --description "hogehoge" --snapshot-names "snap-yymmdd-instanceid" --zone <zone>

Create image

AWSと違い、動いているインスタンスからImage作製は出来ない。terminateしないとダメ
https://developers.google.com/compute/docs/images

$ gcloud compute instances delete <インスタンスID> --keep-disks boot
$ gcloud compute images create <イメージ名> --source-disk <ディスクID> --source-disk-zone

metadata

Full URL: http://metadata.google.internal/computeMetadata/v1/

Shorthand URL: http://metadata/computeMetadata/v1/
IP address: http://169.254.169.254/computeMetadata/v1/

$ curl "http://metadata.google.internal/computeMetadata/v1/instance/disks/0/device-name"  -H "Metadata-Flavor:Google"

Install gsutil (for centos6)

via pyenv

  1. Install pyenv /otp/pyenv
  2. pyenv install 2.7.12
  3. pyenv global 2.7.12 @ root user

virtualenv

  1. install virtualenv @ root user
  2. virtualenv @ normal user
  3. . /bin/activate

gsutil via pip

sudo yum install libffi-devel
pip install cryptography
pip install gsutil

virtualenv & cron

run.sh
#!/bin/bash
~/.virtualenvs/snap-back/bin/python ~/bachup/xxxx.py

0 12 * * * /home/hoge/run.sh

No virtualenv or pyenv user, just use 2.7.x for gcloud

CLOUDSDK_PYTHON=/opt/pyenv/versions/2.7.12/bin/python /usr/local/bin/gcloud -v

To revert gcloud components update

Read result!

To revert your SDK to the previously installed version, you may run:
  $ gcloud components update --version 110.0.0

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1