Spring Boot on GCP
  • Introduction
  • Getting Started
    • Google Cloud Platform
    • Cloud Shell
    • gcloud CLI
    • Hello World!
      • Cloud Shell
      • App Engine
      • Cloud Run
      • Kubernetes Engine
      • Compute Engine
      • Cloud Functions
  • Application Development
    • Development Tools
    • Spring Cloud GCP
    • Cloud Services
      • Databases
        • Cloud SQL
        • Cloud Spanner
        • Cloud Firestore
          • Datastore Mode
          • Native Mode
      • Messaging
        • Cloud Pub/Sub
        • Kafka
      • Secret Management
      • Storage
      • Cache
        • Memorystore Redis
        • Memorystore Memcached (beta)
      • Other Services
    • Observability
      • Trace
      • Logging
      • Metrics
      • Profiling
      • Debugging
    • DevOps
      • Artifact Repository
  • Deployment
    • Runtime Environments
    • Container
      • Container Image
      • Secure Container Image
      • Container Awareness
      • Vulnerability Scanning
      • Attestation
    • Kubernetes
      • Kubernetes Cluster
      • Deployment
      • Resources
      • Service
      • Health Checks
      • Load Balancing
        • External Load Balancing
        • Internal Load Balancing
      • Scheduling
      • Workload Identity
      • Binary Authorization
    • Istio
      • Getting Started
      • Sidecar Proxy
  • Additional Resources
    • Code Labs
    • Presentations / Videos
    • Cheat Sheets
Powered by GitBook
On this page
  • Cloud Shell
  • Local Installation
  • Authenticate
  • Project ID
  • Application Default Credentials
  • Quota Project
  • Default Zone and Region

Was this helpful?

  1. Getting Started

gcloud CLI

Install gcloud command to interact with Google Cloud Platform from the command line.

PreviousCloud ShellNextHello World!

Last updated 3 years ago

Was this helpful?

Cloud Shell

Cloud Shell already has the gcloud CLI pre-installed, so you can skip ahead to .

Jump to the last section to so you do not need to repeatedly specify it.

Local Installation

To install the gcloud CLI on your local machine, follow the for your platform and then follow the below steps to finish configuration.

If you are using Cloud Shell, jump to the last section to so you do not need to repeatedly specify it.

Authenticate

Authenticate gcloud so that it can interact with Google Cloud Platform using your account.

gcloud auth login

This authenticated gcloud so that you can run all the commands.

Project ID

Set the default Project ID to your project.

gcloud config set project YOUR_PROJECT_ID

If you already have a project, run gcloud projects list to list available projects. Find one and then set it as a default project.

Application Default Credentials

In addition to authenticating gcloud, also authenticate Application Default Credentials (ADC). ADC is used by your application/microservices during local development to authenticate with cloud services.

gcloud auth application-default login

Quota Project

API calls to Google Cloud may be rate limited and subject to quotas. The quotas are typically tied to a Google Cloud Project. When you are running the application locally, and using the Application Default Credentials, the requests need to be associated with a project to account for usage quota. Typically, the Quota Project should be the same as the project that you are currently working with. In a larger organization, it can be a Project that's used for development purposes and not the production project.

When configuring the Application Default Credentials the first time, It will also configure a Quota Project to be the same as the default project you previously configured.

If needed, you can configure a different Quota Project:

gcloud auth application-default set-quota-project YOUR_PROJECT_ID

This will store the credential (OAuth refresh token) in a well-known location, such as ~/.config/gcloud/application_default_credentials.json. Google Cloud client libraries can automatically detect this file and use this credential.

Default Zone and Region

A cloud resource can be Zonal, Regional, or Multi-Regional. For example, a VM is Zonal, because it can only live in a single availability zone. App Engine service is regional, because it's automatically distributed across multiple zones within a single Region. Cloud Storage can store your data in a Regional bucket, or a Multi-Regional bucket.

You can always specify the zone or region with each of the gcloud command. If you primarily operate within a single zone or region, set the default zone and default region.

gcloud config set compute/region us-central1
gcloud config set compute/zone us-central1-c
gcloud config set run/region us-central1

Application Default Credentials are used by client libraries when making calls to Google Cloud. This is different from the , which is for gcloud to make calls to Google Cloud.

See the complete list in .

Regions and Zones documentation
official installation guide
configure default zone and region
configure default zone and region
configure default zone and region
first gcloud Authenticate