- 1,235 조회
- 0 추천
# google cheat sheet pdf pdf 파일입니다. > PDF 파일이 미리보기 되지 않을 경우에는 > 이 페이지를 새로고침 하십시오. ![capture 2022-07-12 AM 9.46.46.png](https://goorm.it/data/editor/2207/2890202471_1657586873.5599.png "capture 2022-07-12 AM 9.46.46.png")![capture 2022-07-12 AM 9.46.55.png](https://goorm.it/data/editor/2207/2890202471_1657586873.6701.png "capture 2022-07-12 AM 9.46.55.png") ## GLOBAL FLAGS > Some flags are available throughout the gcloud experience, like: ```bash --help ``` For when in doubt ```bash --project ``` If using a project other than the current one > 현재 프로젝트가 아닌 다른 프로젝트를 사용하는 경우 ```bash --quiet ``` Disable interactive prompts (and apply default values for inputs) > 대화형 프롬프트 사용 안 함(입력 기본값 적용) ```bash --verbosity ``` Can set verbosity levels at debug, info, warning, error, critical, and none ```bash --version ``` Display gcloud version information (only available at the global level) ```bash --format ``` Set output format as config, csv, default, diff, disable, flattened, get, json, list, multi, none, object, table, text, value, or yaml. ## CLEANING UP RESULTS Extricate the most from your output with the filter, format, limit, and sort-by flags. Examples: ```bash gcloud compute instances list --filter="zone ~ ^us AND -machineType:f1-micro" ``` For Compute Engine instances with prefix us and not machine type f1-micro ``` gcloud projects list --format="table(projectNumber,project Id,createTime.date(tz=LOCAL))"\ --filter="createTime>=2018-01-15T12:0 0:00" --sort-by=createTime ``` For a list of projects created on or after 15 January 2018, sorted from oldest to newest, presented as a table with project number, project id and creation time columns with dates and times in local timezone ```bash gcloud compute instances list --filter="labels.my-label:*" --limit=10 ``` For a list of ten Compute Engine instances with a label my-label (of any value) ## DISCOVERING COMMANDS The gcloud command-line tool is a tree; non-leaf nodes are command groups and leaf nodes are commands. (Also, tab completion works for commands and resources!) Most gcloud commands follow the following format: `gcloud` + `release level` (optional) + `component` + `entity operation` + `positional args` + `flags` #### For example: `gcloud` + `compute` + `instances create example instance-1` + `--zone=us-central1-a` #### Where: `Release Level` refers to the command’s release status * `alpha` or` beta`. GA (General Availability commands require no release level specification `Component` refers to different Google Cloud services * compute for Compute Engine, `app` for App Engine, ect. `Entity` refers to the plural form of an element or collection of elements under a component `disks`, `firewalls`, `images`, `instances`, `regions`, `zones` for compute `Operation` refers to the imperative verb form of the operation to be performed on the entity * common operations are `describe, list, create/update, delete/clear, import, export, copy, remove, add, reset, restart, restore, run`, and `deploy` `Positional args` refer to the required, order-specific arguments needed to execute the command * `INSTANCE_NAMES` is the required positional argument for gcloud compute instances create Flags refer to the additional arguments, --flag-name(=value), passed in to the command after positional args * `--machine-type=MACHINE_TYPE` and `--preemptible` are optional flags for gcloud compute instances create # Cheat sheet ## GETTING STARTED ```bash gcloud init ``` Initialize, authorize, and configure gcloud ```bash gcloud version ``` Display version and installed components ```bash gcloud components install ``` Install specific components * ```bash gcloud components update ``` Update the gcloud CLI to the latest version * ```bash gcloud config set project ``` Set a default Google Cloud project to work on ```bash gcloud info ``` Display current gcloud environment details ```bash gcloud help ``` Search gcloud reference documentss for specific terms ```bash gcloud feedback ``` Provide feedback for the gcloud CLI team ```bash gcloud topic ``` Supplementary help material for non-command topics like accessibility, filtering, and formatting * For apt-get and yum, see https://cloud.google.com/sdk/install ## PERSONALIZATION ```bash gcloud config set ``` Define a property (like compute/zone) for current configuration ```bash gcloud config get-value ``` Fetch value of a gcloud CLI property ```bash gcloud config list ``` Display all the properties for the current configuration ```bash gcloud config configura ``` ```bash gcloud config configurations list ``` Display a list of all available confi gurations ```bash gcloud config configurations activate ``` Switch to an ex isting named confi guration ## CREDENTIALS ```bash gcloud auth login ``` Authorize access for gcloud with Google user credentials and set current account as active ```bash gcloud auth activate-service-account ``` Like gcloud auth login but with service account credentials ```bash gcloud auth list ``` List all credentialed accounts ```bash gcloud auth print-access-token ``` Display the current account’s access token ```bash gcloud auth revoke ``` Remove access credentials for an account ```bash gcloud projects describe ``` Display metadata for a project (including its ID) ```bash gcloud projects add-iam-policy-binding ``` Add an IAM policy binding to a project ## GOOGLE KUBERNETES ENGINE (GKE) ```bash gcloud auth configure-docker ``` Register gcloud as a Docker credential helper ```bash gcloud container clusters create ``` C reate a cluster to run G KE containers ```bash gcloud container clusters list ``` List clusters to run G KE containers ```bash gcloud container clusters get-credentials ``` U pdate kubeconfi g to get kubectl to use a G KE cluster ```bash gcloud container images list-tags ``` List tag and digest metadata for a container image ## IDENTITY &ACCESS M ANAGEM ENT (IAM ) ```bash gcloud iam list-grantable-roles ``` List IAM grantable roles for a resource ```bash gcloud iam roles create ``` C reate a custom role for a project or org ```bash gcloud iam service-accounts create ``` C reate a service account for a project ```bash gcloud iam service-accounts keys list ``` List a service account’s keys ```bash gcloud iam service-accounts add-iam-policy-binding ``` Add an IAM policy to a service account ```bash gcloud iam service-accounts set-iam-policy ``` Replace ex isting IAM policy ## COMPUTE ENGINE ```bash gcloud compute zones list ``` List C ompute E ngine zones ```bash gcloud compute instances describe ``` Display a virtual machine (V M) instance’s details ```bash gcloud compute instances list ``` List all V M instances in a project ```bash gcloud compute disks snapshot ``` Create snapshot of persistent disks ```bash gcloud compute snapshots describe ``` Display a specifi ed snapshot’s details ```bash gcloud compute snapshots delete ``` Delete a snapshot ```bash gcloud compute ssh ``` Connect to a V M instance by using SSH ## APP ENGINE ```bash gcloud app deploy ``` Deploy your app’s code and confi guration to App E ngine server ```bash gcloud app versions list ``` List all versions of all services deployed to the App E ngine server ```bash gcloud app brow se ``` Open the current app in a web browser ```bash gcloud app create ``` Create an App E ngine app within your current project ```bash gcloud app logs read ``` Display the latest App E ngine app logs ## MISCELLANEOUS ```bash gcloud kms decrypt ``` Decrypt ciphertex t (to a plaintex t fi le) using a C loud K ey Management S ervice (K MS ) key ```bash gcloud logging logs list ``` List your project’s logs ```bash gcloud sql backups describe ``` Display info about a C loud SQ L instance backup ```bash gcloud sql export sql ``` Export data from a Cloud SQL instance to a SQL file ## INSTALLING THE GCLOUD CLI Docs and installation instructions: https://cloud.google.com/sdk/docs/ ## FLAGS & ARGUM ENTS Arguments can be positional args, which are set after command name and must respect the order of positional args or flags, which are set after positional args where the order of flags doesn’t matter. A flag is either a name-value pair (--foo=bar) or boolean (--force/no-force). Additionally, flags can either be required or optional. When optional, the default value is used if the flag isn’t defi ned.