Google Cloud 命令行工具
gcloud 管理 GCP 的项目、计算、GKE、Cloud Run、日志和 IAM。它使用账号、项目和配置(configuration)三层上下文,gcloud storage 正在替代旧的 gsutil。
gcloud auth login
gcloud auth application-default login
gcloud config set project my-project
gcloud config list
gcloud projects list
gcloud compute instances list
gcloud container clusters get-credentials prod --region=asia-east1
gcloud storage ls gs://my-bucket/
gcloud storage cp -r ./dist gs://my-bucket/dist
gcloud logging read 'resource.type="gce_instance"' --limit=20
gcloud run deploy app --source . --region=asia-east1
gcloud iam service-accounts list
gcloud components update
gcloud auth login 是用户账号,application-default login 是给 SDK/代码用的 ADC;两者不能互相替代。gcloud config list 确认,不要只看命令参数。gcloud auth application-default set-quota-project。gcloud storage 与 gsutil 语法和性能不同;脚本迁移要逐条验证。beta/alpha 命令可能随时变化;生产脚本尽量用 GA 命令。gcloud config configurations;直接改默认账号会影响其他脚本。gsutil — 对象存储旧客户端bq — BigQuery CLIkubectl — GKE 集群操作