Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

gcloud

The command line of Google Cloud: projects, VMs, GKE clusters, Cloud Run, IAM and more.

Niveau
DevOps-tool
Groep
Infrastructuur als code en cloud
Root nodig
Nee
Pakket
google-cloud-cli

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

gcloud works like az and aws: gcloud GROUP COMMAND. Everything belongs to a project; set it once with gcloud config set project. gcloud auth login is for you, service accounts or Workload Identity Federation are for CI (no long-lived keys).

It is part of the Google Cloud CLI, together with gsutil / gcloud storage and bq.

Zo schrijf je het

gcloud GROUP [SUBGROUP] COMMAND [OPTIONS]

Belangrijkste delen

Main groups

auth login / auth list
Log in / show accounts.
config set|list|configurations
Defaults (project, region) and profiles.
projects list
Your projects.
compute instances …
VMs (create, list, ssh, stop).
container clusters …
GKE clusters and their credentials.
run deploy|services
Cloud Run.
storage ls|cp
Cloud Storage buckets.
iam service-accounts / projects add-iam-policy-binding
Identities and roles.
artifacts repositories / docker
Artifact Registry.
logging read
Read logs.

Opties 7

Meest gebruikt

Common flags

--project ID
Project for this command.
--region / --zone
Location.
--format json|yaml|table(…)|value(…)
Output format.
--filter EXPR
Filter the list.
--quiet, -q
No questions (scripts).
--impersonate-service-account SA
Act as a service account.
--verbosity debug
More output.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Log in and set the default project

    gcloud auth login
    gcloud config set project acme-shop-prod
    gcloud config set compute/region europe-west4
  2. 2One profile per environment

    gcloud config configurations create dev
    gcloud config configurations activate prod
  3. 3Get kubeconfig for a GKE cluster

    gcloud container clusters get-credentials shop-gke --region europe-west4
    kubectl get nodes
  4. 4Create a small VM

    gcloud compute instances create web-1 --zone europe-west4-a --machine-type e2-small --image-family rocky-linux-9 --image-project rocky-linux-cloud
  5. 5SSH through IAP (no public IP)

    gcloud compute ssh web-1 --zone europe-west4-a --tunnel-through-iap
  6. 6Deploy a container to Cloud Run

    gcloud run deploy shop --image europe-west4-docker.pkg.dev/acme/apps/shop:1.4.0 --region europe-west4 --no-allow-unauthenticated
  7. 7Docker login for Artifact Registry

    gcloud auth configure-docker europe-west4-docker.pkg.dev
  8. 8Only names and states, as values for a script

    gcloud compute instances list --filter="status=RUNNING" --format="value(name,zone)"
  9. 9Give a service account a role (least privilege)

    gcloud projects add-iam-policy-binding acme-shop-prod --member="serviceAccount:ci@acme-shop-prod.iam.gserviceaccount.com" --role="roles/run.developer"
  10. 10Read the last errors of Cloud Run

    gcloud logging read 'resource.type="cloud_run_revision" AND severity>=ERROR' --limit 20 --freshness 1h
  11. 11Copy files to a bucket

    gcloud storage cp backup.tar.gz gs://acme-backups/2026-10-31/

Let op

  • Service account key files are long-lived secrets; prefer Workload Identity Federation for GitHub Actions.
  • Check the active project (gcloud config list) before you delete anything.

Bestanden

~/.config/gcloud/
Credentials and configurations.

Exitcodes

0OK.
1Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man gcloud