Git Product home page Git Product logo

cheatsheet-gcp-a4's Introduction

1 GCP CheatSheet

linkedin
github
slack


PRs Welcome

File me Issues or star this repo.

1.1 GCP Basic

NameSummary
Official DocLink: gcloud reference, Link: gsutil tool
gsutil installationLink: install crcmod, Link: Install gsutil
InstallationLink: Install gcloud
Check version & settingsgcloud version, gcloud info, gcloud components list
Init profilegcloud init This will ask you to open an OpenID URL
List all zonesgcloud compute zones list
Upgrade local SDKgcloud components update, gcloud components update --version 219.0.1

1.2 Bucket Basic

NameSummary
List all buckets and filesgsutil ls, gsutil ls -lh gs://<bucket-name>
Download filegsutil cp gs://<bucket-name>/<dir-path>/package-1.1.tgz .
Upload filegsutil cp <filename> gs://<bucket-name>/<directory>/
Cat filegsutil cat gs://<bucket-name>/<filepath>/
Delete filegsutil rm gs://<bucket-name>/<filepath>
Move filegsutil mv <src-filepath> gs://<bucket-name>/<directory>/<dest-filepath>
Copy foldergsutil cp -r ./conf gs://<bucket-name>/
Show disk usagegsutil du -h gs://<bucket-name/<directory>
Create bucketgsutil mb gs://<bucket-name>
Caculate file sha1sumgsha1sum syslog-migration-10.0.2.tgz, shasum syslog-migration-10.0.2.tgz
Gsutil helpgsutil help, gsutil help cp, gsutil help options
ReferenceLink: Quickstart: Using the gsutil Tool

1.3 GCP Project

NameSummary
List projectsgcloud config list, gcloud config list project
Show project infogcloud compute project-info describe
Switch projectgcloud config set project <project-id>

1.4 GKE

NameSummary
Display a list of credentialed accountsgcloud auth list
Set the active accountgcloud config set account <ACCOUNT>
Set kubectl contextgcloud container clusters get-credentials <cluster-name>
Change regiongcloud config set compute/region us-west
Change zonegcloud config set compute/zone us-west1-b
List all container clustersgcloud container clusters list

1.5 IAM

NameSummary
Authenticate clientgcloud auth activate-service-account --key-file <key-file>
Display a list of credentialed accountsgcloud auth list
Set the active accountgcloud config set account <ACCOUNT>
Auth to GCP Container Registrygcloud auth configure-docker
Print token for active accountgcloud auth print-access-token, gcloud auth print-refresh-token
Revoke previous generated credentialgcloud auth <application-default> revoke

1.6 Bucket Security

NameSummary
Make all files readablegsutil -m acl set -R -a public-read gs://<bucket-name>/
Config authgsutil config -a
Grant bucket accessgsutil iam ch user:[email protected]:objectCreator,objectViewer gs://<bucket-name>
Remove bucket accessgsutil iam ch -d user:[email protected]:objectCreator,objectViewer gs://<bucket-name>

1.7 VM

NameSummary
List all instancesgcloud compute instances list, gcloud compute instance-templates list
Show instance infogcloud compute instances describe "<instance-name>" --project "<project-name>" --zone "us-west2-a"
Stop an instancegcloud compute instances stop instance-2
Start an instancegcloud compute instances start instance-2
Create an instancegcloud compute instances create vm1 --image image-1 --tags test --zone "<zone>" --machine-type f1-micro
SSH to instancegcloud compute ssh --project "<project-name>" --zone "<zone-name>" "<instance-name>"
Download filesgcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a
Upload filesgcloud compute copy-files ~/LOCAL-FILE-1 example-instance:~/REMOTE-DIR --zone us-central1-a

1.8 Disks & Volumes

NameSummary
List all disksgcloud compute disks list
List all disk typesgcloud compute disk-types list
List all snapshotsgcloud compute snapshots list
Create snapshotgcloud compute disks snapshot <diskname> --snapshotname <name1> --zone $zone

1.9 Network

NameSummary
List all networksgcloud compute networks list
Detail of one networkgcloud compute networks describe <network-name> --format json
Create networkgcloud compute networks create <network-name>
Create subnetgcloud compute networks subnets create subnet1 --network net1 --range 10.5.4.0/24
Get a static ipgcloud compute addresses create --region us-west2-a vpn-1-static-ip
List all ip addressesgcloud compute addresses list
Describe ip addressgcloud compute addresses describe <ip-name> --region us-central1
List all routesgcloud compute routes list
Referencealeccunningham gist: vpn-setup.sh

1.10 DNS

NameSummary
List of all record-sets in my_zonegcloud dns record-sets list --zone my_zone
List first 10 DNS recordsgcloud dns record-sets list --zone my_zone --limit=10

1.11 Firewall

NameSummary
List all firewall rulesgcloud compute firewall-rules list
List all forwarding rulesgcloud compute forwarding-rules list
Describe one firewall rulegcloud compute firewall-rules describe <rule-name>
Create one firewall rulegcloud compute firewall-rules create my-rule --network default --allow tcp:9200 tcp:3306
Update one firewall rulegcloud compute firewall-rules update default --network default --allow tcp:9200 tcp:9300

1.12 Images & Containers

NameSummary
List all imagesgcloud compute images list
List all container clustersgcloud container clusters list
Set kubectl contextgcloud container clusters get-credentials <cluster-name>

1.13 RDS

NameSummary
List all sql instancesgcloud sql instances list

1.14 Services

NameSummary
List my backend servicesgcloud compute backend-services list
List all my health check endpointsgcloud compute http-health-checks list
List all URL mapsgcloud compute url-maps list

1.15 More Resources

kelseyhightower gist: create-global-lb.sh

mingderwang gist: gistfile1.txt

License: Code is licensed under MIT License.

linkedin github slack

cheatsheet-gcp-a4's People

Contributors

dennyzhang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.