3

GCP常用命令(gcloud、gsutil)

 3 years ago
source link: https://www.pkslow.com/archives/gcp-commands
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
技术之前,先读诗书:

低声问向谁行宿,城上已三更。

gcloud

Config

初始化配置:

gcloud init

列出配置信息:

gcloud projects list
gcloud auth list
gcloud config list
gcloud config set project 'projectId'
gcloud config set account 'ACCOUNT'

使用Json授权ServiceAccount:

gcloud auth activate-service-account --key-file xxxx.json

获取GKE Cluster鉴权信息:

gcloud container clusters get-credentials 'cluster-name' --region=xxx

安装Components:

gcloud components install beta

compute

gcloud compute instances list
gcloud compute instance-groups list
gcloud compute instance-templates list

SSH连接:

gcloud compute ssh example-instance --zone=us-central1-a
gcloud compute ssh example-instance --zone=us-central1-a  --command="ps -ejH"

Pub/Sub相关

列出Topic和subscriptions:

gcloud pubsub topics list
gcloud pubsub subscriptions list

创建 ID 为 my-topic 的主题:

gcloud pubsub topics create my-topic

创建 ID 为 my-sub 的订阅,并将其附加到 my-topic

gcloud pubsub subscriptions create my-sub --topic=my-topic

将消息发布到 my-topic

gcloud pubsub topics publish my-topic --message="hello"

接收来自 my-sub 的消息:

gcloud pubsub subscriptions pull my-sub --auto-ack

gcloud 工具会将消息输出到命令行。

gsutil

列出项目的buckets:

gsutil ls gs://

列出bucket文件:

gsutil ls gs://<bucketName>

复制文件:

gsutil cp localFile gs://xxx
gsutil cp gs://xxx localPath

欢迎关注微信公众号<南瓜慢说>,将持续为你更新...

推荐阅读:
如何制定切实可行的计划并好好执行
容器技术(Docker-Kubernetes)
SpringBoot-Cloud相关
Https专题


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK