Getting Started with gcloud Commands on GCP.

gcloud is the command-line interface (CLI) for the Google Cloud Platform (GCP). Gcloud commands allows users to interact with GCP resources and services, including managing virtual machines, deploying applications, configuring networking, and more.

With gcloud, users can manage their GCP resources from their local machine without using the web console. The gcloud CLI can be installed on Windows, Linux, and macOS machines.

gcloud provides a set of commands that can be used to perform various operations on GCP resources, such as creating and managing virtual machines, creating and managing storage buckets, and managing network configurations.

Users can also use gcloud to interact with services like Google Kubernetes Engine (GKE), Google Cloud Storage, and Google Cloud SQL. gcloud commands can be run in a terminal window or incorporated into scripts for automated workflows.

How to manage oauth2 credentials in GCP

The gcloud auth commands are used to add and remove access to the Google Cloud CLI. If you come from an AWS background, Google Auth works exactly the same as AWS SSO.

To manage OAuth2 credentials in Google Cloud Platform (GCP), you can use the Cloud Console or the gcloud command-line tool. Here are the general steps:

  1. Create a project in the GCP Console if you haven’t already done so.
  2. Go to the APIs & Services Dashboard and click on the “+CREATE CREDENTIALS” button.
  3. Select “OAuth client ID” from the dropdown menu.
  4. Choose your application type (Web application, Android, iOS, or Desktop app) and provide the required information.
  5. Once the OAuth2 client ID is created, you can view, edit, or delete it from the Credentials page in the Console.
  6. To use the client ID in your application, you’ll need to configure your application to use the OAuth2 flow appropriate for your application type. This will typically involve redirecting users to a Google sign-in page and obtaining an authorization code or token that can be used to make API requests on behalf of the user.

To manage OAuth2 credentials using the gcloud command-line tool, you can use the gcloud auth application-default command. This command sets up application default credentials for your local development environment.

Here are the general steps:

Step 1 – Install the GCLOUD Command Line Tool

If you are using Debian / Ubuntu – use these commands as a short cut

Bash
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-462.0.1-linux-x86_64.tar.gz
tar -xf google-cloud-cli-462.0.1-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh

You will get output similar to this:

Bash
Welcome to the Google Cloud CLI!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. This data is
handled in accordance with our privacy policy
<https://cloud.google.com/terms/cloud-privacy-notice>. You may choose to opt in this
collection now (by choosing 'Y' at the below prompt), or at any time in the
future by running the following command:

    gcloud config set disable_usage_reporting false

Do you want to help improve the Google Cloud CLI (y/N)?  n


Your current Google Cloud CLI version is: 462.0.1
The latest available version is: 462.0.1

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
                                                    Components                                                   
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────────┬───────────┤
     Status                             Name                                       ID                  Size   
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────────┼───────────┤
 Not Installed  App Engine Go Extensions                              app-engine-go                   4.7 MiB 
 Not Installed  Appctl                                                appctl                         21.0 MiB 
 Not Installed  Artifact Registry Go Module Package Helper            package-go-module               < 1 MiB 
 Not Installed  Cloud Bigtable Command Line Tool                      cbt                            16.5 MiB 
 Not Installed  Cloud Bigtable Emulator                               bigtable                        7.1 MiB 
 Not Installed  Cloud Datastore Emulator                              cloud-datastore-emulator       36.2 MiB 
 Not Installed  Cloud Firestore Emulator                              cloud-firestore-emulator       42.8 MiB 
 Not Installed  Cloud Pub/Sub Emulator                                pubsub-emulator                62.1 MiB 
 Not Installed  Cloud Run Proxy                                       cloud-run-proxy                13.3 MiB 
 Not Installed  Cloud SQL Proxy                                       cloud_sql_proxy                 7.8 MiB 
 Not Installed  Cloud Spanner Emulator                                cloud-spanner-emulator         36.0 MiB 
 Not Installed  Cloud Spanner Migration Tool                          harbourbridge                  20.9 MiB 
 Not Installed  Google Container Registry's Docker credential helper │ docker-credential-gcr        │   1.8 MiB │
│ Not Installed │ Kustomize                                            │ kustomize                    │   4.3 MiB │
│ Not Installed │ Log Streaming                                        │ log-streaming                │  13.9 MiB │
│ Not Installed │ Minikube                                             │ minikube                     │  35.4 MiB │
│ Not Installed │ Nomos CLI                                            │ nomos                        │  28.7 MiB │
│ Not Installed │ On-Demand Scanning API extraction helper             │ local-extract                │  14.4 MiB │
│ Not Installed │ Skaffold                                             │ skaffold                     │  23.4 MiB │
│ Not Installed │ Spanner migration tool                               │ spanner-migration-tool       │  23.5 MiB │
│ Not Installed │ Terraform Tools                                      │ terraform-tools              │  66.1 MiB │
│ Not Installed │ anthos-auth                                          │ anthos-auth                  │  21.8 MiB │
│ Not Installed │ config-connector                                     │ config-connector             │  56.7 MiB │
│ Not Installed │ enterprise-certificate-proxy                         │ enterprise-certificate-proxy │   8.6 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                        │   < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta                         │   < 1 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java              │ 125.9 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python            │   8.4 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras     │  31.5 MiB │
│ Not Installed │ gke-gcloud-auth-plugin                               │ gke-gcloud-auth-plugin       │   7.9 MiB │
│ Not Installed │ kpt                                                  │ kpt                          │  14.4 MiB │
│ Not Installed │ kubectl                                              │ kubectl                      │   < 1 MiB │
│ Not Installed │ kubectl-oidc                                         │ kubectl-oidc                 │  21.8 MiB │
│ Not Installed │ pkg                                                  │ pkg                          │           │
│ Installed     │ BigQuery Command Line Tool                           │ bq                           │   1.6 MiB │
│ Installed     │ Bundled Python 3.11                                  │ bundled-python3-unix         │  73.8 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                       │  11.3 MiB │
│ Installed     │ Google Cloud CLI Core Libraries                      │ core                         │  22.4 MiB │
│ Installed     │ Google Cloud CRC32C Hash Tool                        │ gcloud-crc32c                │   1.2 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────────┴───────────┘
To install or remove components at your current SDK version [462.0.1], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [462.0.1], run:
  $ gcloud components update


Modify profile to update your $PATH and enable shell command completion?

Do you want to continue (Y/n)?  y

The Google Cloud SDK installer will now prompt you to update an rc file to bring the Google Cloud 
CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use [/home/rbailey/.bashrc]:  
Backing up [/home/rbailey/.bashrc] to [/home/rbailey/.bashrc.backup].
[/home/rbailey/.bashrc] has been updated.

==> Start a new shell for the changes to take effect.


For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts

You need to close your terminal and reopen to pick up GCLOUD.

Elsewhere On TurboGeek:  Plex Media Server Setup Guide

Step 2 – Update Gcloud Components (Optional)

If you want to install all of the gcloud components issue this command

Bash
gcloud components install `gcloud components list | grep "Not Installed" | awk -F '│' '{print $4}' | xargs`

You will see the following output. Note: Installation can take several minutes.

Bash
gcloud components install `gcloud components list | grep "Not Installed" | awk -F '│' '{print $4}' | xargs`

Your current Google Cloud CLI version is: 462.0.1
The latest available version is: 462.0.1

To install or remove components at your current SDK version [462.0.1], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [462.0.1], run:
  $ gcloud components update



Your current Google Cloud CLI version is: 462.0.1
Installing components from version: 462.0.1

┌──────────────────────────────────────────────────────────────────────────────────┐
                       These components will be installed.                        
├──────────────────────────────────────────────────────┬───────────────┬───────────┤
                         Name                             Version        Size   
├──────────────────────────────────────────────────────┼───────────────┼───────────┤
 App Engine Go Extensions                                     1.9.76    4.7 MiB 
 Appctl                                                       0.1.12   21.0 MiB 
 Artifact Registry Go Module Package Helper                    0.4.0    < 1 MiB 
 Cloud Bigtable Command Line Tool                             1.17.2   16.5 MiB 
 Cloud Bigtable Emulator                                                7.1 MiB 
 Cloud Datastore Emulator                                      2.3.1   36.2 MiB 
 Cloud Firestore Emulator                                     1.18.2   42.8 MiB 
 Cloud Pub/Sub Emulator                                       0.8.10   62.1 MiB 
 Cloud Run Proxy                                               0.5.0   13.3 MiB 
 Cloud SQL Proxy                                              1.27.0    7.8 MiB 
 Cloud Spanner Emulator                                       1.5.13   36.0 MiB 
 Cloud Spanner Migration Tool                                  3.0.0   20.9 MiB 
 Google Container Registry's Docker credential helper │         1.5.0 │   1.8 MiB │
│ Kustomize                                            │         4.4.0 │   4.3 MiB │
│ Log Streaming                                        │         0.3.0 │  13.9 MiB │
│ Minikube                                             │        1.32.0 │  35.4 MiB │
│ Nomos CLI                                            │   1.17.0-rc.4 │  28.7 MiB │
│ On-Demand Scanning API extraction helper             │         1.5.9 │  14.4 MiB │
│ Skaffold                                             │         2.9.0 │  23.4 MiB │
│ Spanner migration tool                               │         3.2.2 │  23.5 MiB │
│ Terraform Tools                                      │        0.11.1 │  66.1 MiB │
│ anthos-auth                                          │         1.5.0 │  21.8 MiB │
│ config-connector                                     │        1.93.0 │  56.7 MiB │
│ enterprise-certificate-proxy                         │         0.3.2 │   8.6 MiB │
│ gRPC Python library                                  │        1.20.0 │   2.1 MiB │
│ gcloud Alpha Commands                                │    2024.01.31 │   < 1 MiB │
│ gcloud Beta Commands                                 │    2024.01.31 │   < 1 MiB │
│ gcloud app Java Extensions                           │        2.0.24 │ 125.9 MiB │
│ gcloud app Python Extensions                         │       1.9.108 │   8.4 MiB │
│ gcloud app Python Extensions (Extra Libraries)       │       1.9.102 │  31.5 MiB │
│ gke-gcloud-auth-plugin                               │         0.5.8 │   7.9 MiB │
│ kpt                                                  │ 1.0.0-beta.49 │  14.4 MiB │
│ kubectl                                              │        1.27.9 │  99.9 MiB │
│ kubectl                                              │        1.27.9 │   < 1 MiB │
│ kubectl-oidc                                         │         1.5.0 │  21.8 MiB │
└──────────────────────────────────────────────────────┴───────────────┴───────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?  y

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go Extensions                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go Extensions                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Appctl                                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Appctl                                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Artifact Registry Go Module Package Helper   ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Artifact Registry Go Module Package Helper   ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Bigtable Command Line Tool             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Bigtable Command Line Tool             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Bigtable Emulator                      ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Bigtable Emulator                      ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Datastore Emulator                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Firestore Emulator                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Pub/Sub Emulator                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Run Proxy                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Run Proxy                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud SQL Proxy                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud SQL Proxy                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Spanner Emulator                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Spanner Emulator                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Spanner Migration Tool                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Spanner Migration Tool                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Google Container Registry's Docker creden... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Google Container Registry's Docker creden... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Kustomize                                    ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Kustomize                                    ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Log Streaming                                ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Log Streaming                                ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Minikube                                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Minikube                                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Nomos CLI                                    ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Nomos CLI                                    ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: On-Demand Scanning API extraction helper     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: On-Demand Scanning API extraction helper     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Skaffold                                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Skaffold                                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Spanner migration tool                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Spanner migration tool                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Terraform Tools                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Terraform Tools                              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: anthos-auth                                  ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: anthos-auth                                  ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: config-connector                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: config-connector                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: enterprise-certificate-proxy                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: enterprise-certificate-proxy                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gRPC Python library                          ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gRPC Python library                          ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud Alpha Commands                        ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud Beta Commands                         ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Java Extensions                   ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Python Extensions                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Python Extensions (Extra Libra... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gke-gcloud-auth-plugin                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gke-gcloud-auth-plugin                       ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kpt                                          ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kpt                                          ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl                                      ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl                                      ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl-oidc                                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl-oidc                                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: pkg                                          ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation          ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done.                                                                                                                                                                   

Update done!

Step 3 – Authenticate Gcloud with your Gcloud Account

Open a terminal window and run the following command to authenticate with your GCP account:

Bash
gcloud auth login

This will open a Web Browser for you to log into your Google Account.

Once you’ve authenticated, run the following command to set up application default credentials:

ShellScript
gcloud auth application-default login

This will generate a new OAuth2 client ID and store it locally.

To view or manage your application default credentials, run the following command:

ShellScript
gcloud auth application-default --help 


This will show you the available options for managing your credentials.

Note that application default credentials are typically used for local development and testing. In production, you should use a more secure authentication method, such as service accounts.

Elsewhere On TurboGeek:  GCP Load Balancing


Step 4 – How to Create and Manipulate Compute Engine Resources.

The bulk of the gcloud commands are kept under gcloud compute group. This selection manages all GCP resources.

All commands start gcloud compute

ShellScript
  Compute
      firewall-policies
      Manage Compute Engine organization firewall policies.

      machine-images
      Read and manage Compute Engine machine image resources.

      network-firewall-policies
      Manage Compute Engine network firewall policies.

      reservations
      Manage Compute Engine reservations.

      resource-policies
      Manage Compute Engine Resource Policies.

  Disks
      disk-types
      Read Compute Engine virtual disk types.

      disks
      Read and manipulate Compute Engine disks.

  Info
      accelerator-types
      Read Compute Engine accelerator types.

      machine-types
      Read Compute Engine virtual machine types.

      operations
      Read and manipulate Compute Engine operations.

      regions
      List Compute Engine regions.

      zones
      List Compute Engine zones.

  Instances
      commitments
      Manage Compute Engine commitments.

      diagnose
      Debugging tools for Compute Engine virtual machine instances.

      images
      List, create, and delete Compute Engine images.

      instance-groups
      Read and manipulate Compute Engine instance groups.

      instance-templates
      Read and manipulate Compute Engine instances templates.

      instances
      Read and manipulate Compute Engine virtual machine instances.

      snapshots
      List, describe, and delete Compute Engine snapshots.

      sole-tenancy
      Read and manage Compute Engine sole-tenancy resources.

      target-instances
      Read and manipulate Compute Engine virtual target instances.

      tpus
      List, create, and delete Cloud TPUs.

  Load Balancing
      backend-buckets
      Read and manipulate backend buckets.

      backend-services
      List, create, and delete backend services.

      forwarding-rules
      Read and manipulate traffic forwarding rules to network load balancers.

      health-checks
      Read and manipulate health checks for load balanced instances.

      http-health-checks
      Read and manipulate HTTP health checks for load balanced instances.

      https-health-checks
      Read and manipulate HTTPS health checks for load balanced instances.

      security-policies
      Read and manipulate Cloud Armor security policies.

      ssl-certificates
      List, create, and delete Compute Engine SSL certificate resources.

      ssl-policies
      List, create, delete and update Compute Engine SSL policies.

      target-pools
      Control Compute Engine target pools for network load balancing.

  Networking
      addresses
      Read and manipulate Compute Engine addresses.

      external-vpn-gateways
      List, create, delete and update External VPN Gateways.

      firewall-rules
      List, create, update, and delete Compute Engine firewall rules.

      interconnects
      Read and manipulate Compute Engine interconnects.

      network-endpoint-groups
      Read and manipulate Compute Engine network endpoint groups.

      networks
      List, create, and delete Compute Engine networks.

      packet-mirrorings
      Manage Compute Engine packet mirroring resources.

      public-advertised-prefixes
      Manage public advertised prefix resources.

      public-delegated-prefixes
      Manage public delegated prefix resources.

      routers
      List, create, and delete Compute Engine routers.

      routes
      Read and manipulate routes.

      service-attachments
      Manage Compute Engine service attachment resources.

      shared-vpc
      Configure shared VPC.

      target-grpc-proxies
      Manage Compute Engine target gRPC proxy resources.

      target-http-proxies
      List, create, and delete target HTTP proxies.

      target-https-proxies
      List, create, and delete target HTTPS proxies.

      target-ssl-proxies
      List, create, and delete target SSL proxies.

      target-tcp-proxies
      List, create, and delete target TCP proxies.

      target-vpn-gateways
      Read and manipulate classic VPN gateways.

      url-maps
      List, create, and delete URL maps.

      vpn-gateways
      read and manipulate Highly Available VPN Gateways.

      vpn-tunnels
      Read and manipulate Compute Engine VPN tunnels.

  Tools
      os-config
      Manage OS Config tasks for Compute Engine VM instances.

      os-login
      Create and manipulate Compute Engine OS Login resources.

      project-info
      Read and manipulate project-level data like quotas and metadata.

Available commands for gcloud compute:

  Other
      copy-files
      *(DEPRECATED)*  Copy files to and from Google Compute Engine virtual machines via scp.

      start-iap-tunnel
      Starts an IAP TCP forwarding tunnel.

  Tools
      config-ssh
      Populate SSH config files with Host entries from each instance.

      connect-to-serial-port
      Connect to the serial port of an instance.

      reset-windows-password
      Reset and return a password for a Windows machine instance.

      scp
      Copy files to and from Google Compute Engine virtual machines via scp.

      sign-url
      Sign specified URL for use with Cloud CDN Signed URLs.

      ssh
      SSH into a virtual machine instance.

Here are the general steps to create and manipulate Compute Engine resources using the gcloud command-line tool:

  1. Install the gcloud command-line tool if you haven’t already done so.
  2. Authenticate with your GCP account by running the following command and following the on-screen prompts:
ShellScript
gcloud auth login

Create a new Compute Engine instance by running the following command:

ShellScript
gcloud compute instances create INSTANCE-NAME --machine-type MACHINE-TYPE --image IMAGE-NAME --zone ZONE

Replace INSTANCE-NAME with a name for your instance, MACHINE-TYPE with the machine type you want to use (e.g., n1-standard-1), IMAGE-NAME with the name of the image you want to use (e.g., ubuntu-2004-lts), and ZONE with the zone you want to create the instance in (e.g., us-central1-a).

List your Compute Engine instances by running the following command:

ShellScript
gcloud compute instances list

This will show you a list of all your instances and their current status.

Connect to your instance by running the following command:

ShellScript
gcloud compute ssh INSTANCE-NAME --zone ZONE

Replace INSTANCE-NAME with the name of the instance you want to connect to and ZONE with the zone it’s in.

Stop or start an instance by running the following command:

ShellScript
gcloud compute instances stop INSTANCE-NAME --zone ZONE

or

ShellScript
gcloud compute instances start INSTANCE-NAME --zone ZONE

Replace INSTANCE-NAME with the name of the instance you want to stop or start, and ZONE with the zone it’s in.

Delete an instance by running the following command:

ShellScript
gcloud compute instances delete INSTANCE-NAME --zone ZONE Replace INSTANCE-NAME with the name of the instance you want to delete, and ZONE with the zone it's in.

These are just a few examples of the many things you can do with the gcloud command-line tool and Compute Engine. You can find more information and examples in the gcloud documentation.

How to edit Google Cloud CLI properties?

The gcloud config command group lets you set, view and unset properties Google Cloud CLI uses.

Remember you can use gcloud info to learn about your current properties and environmental variables

ShellScript
gcloud config
gcloud config list
gcloud config set
gcloud config unset

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »