gcloud core concepts
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have learned how to install and configure gcloud.
https://cloudaffaire.com/gcloud-installation-and-configuration/
In this blog post, we will discuss some of the core concepts for gcloud.
gcloud core concepts:
The gcloud CLI is a part of the Google Cloud SDK. You must download and install the SDK on your system and initialize it before you can use the gcloud command-line tool. By default, the SDK installs those gcloud CLI commands that are at the General Availability level only. Additional functionality is available in SDK components named alpha and beta. These components allow you to use the gcloud CLI to work with Google Cloud Bigtable, Google Cloud Dataflow and other parts of the Cloud Platform at earlier release levels than General Availability.
Release levels:
- General Availability: Commands are considered fully stable and available for production use. Advance warnings will be made for commands that break current functionality and documented in the release notes.
- Beta: Commands are functionally complete, but may still have some outstanding issues. Breaking changes to these commands may be made without notice.
- Alpha: Commands are in early release and may change without notice.
Command groups:
Within each release level, gcloud CLI commands are organized into a nested hierarchy of command groups, each of which represents a product or feature of the Cloud Platform or its functional subgroups.
Example:
- gcloud compute: Commands related to Compute Engine in general availability
- gcloud compute instances: Commands related to Compute Engine instances in general availability
- gcloud beta compute: Commands related to Compute Engine in Beta
- gcloud alpha app: Commands related to managing App Engine deployments in Alpha
Properties:
gcloud CLI properties are settings that affect the behavior of the gcloud CLI and other Cloud SDK tools. Some of these properties can be set by either global or command flags – in which case, the value set by the flag takes precedence.
Configurations:
A configuration is a named set of gcloud CLI properties. It works like a profile, essentially. Starting off with Cloud SDK, you’ll work with a single configuration named default and you can set properties by running either gcloud init or gcloud config set. This single default configuration is suitable for most use cases. If you’d like to work with multiple projects or authorization accounts, you can set up multiple configurations with gcloud config configurations create and switch among them accordingly.
Global flags:
The gcloud CLI provides a set of gcloud CLI-wide flags that govern the behavior of commands on a per-invocation level. Flags override any values set in SDK properties.
Positional Arguments and Flags:
While both positional arguments and flags affect the output of a gcloud CLI command, there is a subtle difference in their use cases. A positional argument is used to define an entity on which a command operates while a flag is required to set a variation in a command’s behavior.
Demo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
########################## ## gcloud core concepts ## ########################## ## To list the configurations in your Cloud SDK installation gcloud config configurations list ## To view the properties in a configuration gcloud config configurations describe ## To view properties in the active configuration gcloud config list ## To set and unset the properties in the active configuration gcloud config set project gcloud config set zone gcloud config unset disable_usage_reporting ## To delete a configuration gcloud config configurations delete ## gcloud syntax gcloud # GROUP: # ------ # access-context-manager: Manage Access Context Manager resources. # active-directory: Manage Managed Microsoft AD resources. # ai-platform: Manage AI Platform jobs and models. # alpha: (ALPHA) Alpha versions of gcloud commands. # app: Manage your App Engine deployments. # asset: Manage the Cloud Asset Inventory. # auth: Manage oauth2 credentials for the Google Cloud SDK. # beta: (BETA) Beta versions of gcloud commands. # bigtable: Manage your Cloud Bigtable storage. # builds: Create and manage builds for Google Cloud Build. # components: List, install, update, or remove Google Cloud SDK components. # composer: Create and manage Cloud Composer Environments. # compute: Create and manipulate Google Compute Engine resources. # config: View and edit Cloud SDK properties. # container: Deploy and manage clusters of machines for running containers. # dataflow: Manage Google Cloud Dataflow resources. # dataproc: Create and manage Google Cloud Dataproc clusters and jobs. # datastore: Manage your Cloud Datastore indexes. # debug: Commands for interacting with the Cloud Debugger. # deployment-manager: Manage deployments of cloud resources. # dns: Manage your Cloud DNS managed-zones and record-sets. # domains: Manage domains for your Google Cloud projects. # endpoints: Create, enable and manage API services. # filestore: Create and manipulate Cloud Filestore resources. # firebase: Work with Google Firebase. # firestore: Manage your Cloud Firestore resources. # functions: Manage Google Cloud Functions. # iam: Manage IAM service accounts and keys. # iot: Manage Cloud IoT resources. # kms: Manage cryptographic keys in the cloud. # logging: Manage Stackdriver Logging. # ml: Use Google Cloud machine learning capabilities. # ml-engine: Manage AI Platform jobs and models. # organizations: Create and manage Google Cloud Platform Organizations. # policy-troubleshoot: Troubleshoot Google Cloud Platform policies. # projects: Create and manage project access policies. # pubsub: Manage Cloud Pub/Sub topics, subscriptions, and snapshots. # redis: Manage Cloud Memorystore Redis resources. # resource-manager: Manage Cloud Resources. # run: Manage your Cloud Run applications. # scheduler: Manage Cloud Scheduler jobs and schedules. # services: List, enable and disable APIs and services. # source: Cloud git repository commands. # spanner: Command groups for Cloud Spanner. # sql: Create and manage Google Cloud SQL databases. # tasks: Manage Cloud Tasks queues and tasks. # topic: gcloud supplementary help. # COMMANDS: # --------- # docker: (DEPRECATED) Enable Docker CLI access to Google Container Registry. # feedback: Provide feedback to the Google Cloud SDK team. # help: Search gcloud help text. # info: Display information about the current gcloud environment. # init: Initialize or reinitialize gcloud. # survey: Invoke a customer satisfaction survey for Cloud SDK. # version: Print version information for Cloud SDK components. # GLOBAL FLAGS: # ------------- # --account=ACCOUNT (Google Cloud Platform user account to use for invocation) # --billing-project=BILLING_PROJECT (The Google Cloud Platform project that will be charged quota for operations performed in gcloud) # --configuration=CONFIGURATION (The configuration to use for this command invocation) # --flags-file=YAML_FILE (A YAML or JSON file for specifying complex flag values with special characters that work with any command interpreter) # --flatten=[KEY,…] (Flatten name[] output resource slices in KEY into separate records for each item in each slice) # --format=FORMAT (Set the format for printing command output resources) # --help (Display detailed help) # --project=PROJECT_ID (The Google Cloud Platform project name to use for this invocation. If omitted, then the current project is assumed) # --quiet, -q (Disable all interactive prompts when running gcloud commands) # --verbosity=VERBOSITY; default="warning" (Override the default verbosity for this command) # --version, -v (Print version information and exit) # -h (Print a summary help and exit) # OTHER FLAGS: # ------------ # --impersonate-service-account=SERVICE_ACCOUNT_EMAIL (For this gcloud invocation, all API requests will be made as the given service account) # --log-http (Log all HTTP server requests and responses to stderr) # --trace-token=TRACE_TOKEN (Token used to route traces of service requests for investigation of issues) # --user-output-enabled (Print user intended output to the console) ## Getting help for gcloud gcloud help compute gcloud help compute images gcloud help compute images list ## Example gcloud command to list images of centos7-family gcloud compute images list --filter="family=centos-7" ## Output only the image name gcloud compute images list --filter="family=centos-7" --format="value(selfLink.scope())" |
Hope you have enjoyed this blog post.
To get more details on gcloud and Google cloud SDK, please refer below GCP documentation
https://cloud.google.com/sdk/docs/
https://cloud.google.com/sdk/docs/properties
https://cloud.google.com/blog/products/gcp/filtering-and-formatting-fun-with
https://cloud.google.com/sdk/gcloud/reference/