安装google cloud sdk的时候第一次需要初始化,而初始化的时候因为一些原因,
会报错:
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
ERROR: Reachability Check failed.
Cannot reach https://www.google.com (ServerNotFoundError)
Cannot reach https://accounts.google.com (ServerNotFoundError)
Cannot reach https://cloudresourcemanager.googleapis.com/v1beta1/projects (ServerNotFoundError)
Cannot reach https://www.googleapis.com/auth/cloud-platform (ServerNotFoundError)
Cannot reach https://dl.google.com/dl/cloudsdk/channels/rapid/components-2.json (ServerNotFoundError)
Network connection problems may be due to proxy or firewall settings.
。
或者下面卡很久
Network diagnostic detects and fixes local network connection issues.
Checking network connection...
自己的电脑直接科学上网也不行,谷歌文档中是这么说的:
如果您位于公司代理或防火墙后面,gcloud 命令行工具可能无法使用默认设置访问互联网。
以下是正确配置google cloud sdk的方法,首先自己的电脑能够科学上网,其次通过以下三行配置sdk的proxy
config set proxy/type socks5
config set proxy/address 127.0.0.1
gcloud config set proxy/port 1080
以下是全部命令与流程
Welcome to the Google Cloud SDK! Run "gcloud -h" to get the list of available commands.
---
D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/type socks5
Updated property [proxy/type].
D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/address 127.0.0.1
Updated property [proxy/address].
D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/port 1080
Updated property [proxy/port].
D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud init
Welcome! This command will take you through the configuration of gcloud.
Settings from your current configuration [proxyconfig0] are:
core:
disable_usage_reporting: 'False'
proxy:
address: 127.0.0.1
port: '1080'
type: socks5
Pick configuration to use:
[