【问题标题】:How to make google-cloud-sdk work behind the proxy?如何让 google-cloud-sdk 在代理后面工作?
【发布时间】:2022-01-07 19:06:54
【问题描述】:

使用 google-cloud-sdk 时,会注意到以下行为。对于第 2 点中的失败案例,目标是具有与下面提到的第 1 点相同的行为。这将确保 gcloud 在代理后面的工作。帮忙?

  1. 可以通过 Powershell 激活服务帐户(在 Windows 代理设置中手动设置代理的情况下)。以下是成功案例的样子。

    PS C:\Users\monica.bostina\Downloads\DLP1\Attended Framework> gcloud config list
    [core]
    account = vf-grp-dlplt-dev-dlp01@appspot.gserviceaccount.com
    disable_user_reporting = True
    project = vf-grp-dlplt-dev-dlp01
    
    Your active configuration is: [default]
    PS C:\Users\monica.bostina\Downloads\DLP1\Attended Framework> gcloud auth activate-service-account --key-file="temporary-credentials.json" 
    

    激活的服务帐户凭据:[vf-grp-dlplt-dev-dlp01@appspot.gserviceaccount.com]

  2. 未能通过 Powershell 激活服务帐户(如果 Windows 代理设置中的“使用代理设置”为“开”且“手动代理设置”为“关”)。错误消息如下。

PS C:\Users\monica.bostina\Downloads\DLP1\Attended Framework> gcloud config list
[core]
account = vf-grp-dlplt-dev-dlp01@appspot.gserviceaccount.com
disable_user_reporting = True
project = vf-grp-dlplt-dev-dlp01    

Your active configuration is: [default]
PS C:\Users\monica.bostina\Downloads\DLP1\Attended Framework> gcloud auth activate-service-account --key-file="temporary-credentials.json" 
ERROR: gcloud crashed (TransportError): HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000199D6670DF0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
If you would like to report this issue, please run the following command:
gcloud feedback
        
To check gcloud for common problems, please run the following command:
gcloud info --run-diagnostics

我在处理 VPN 和代理的公司环境中工作。 在代理级别将以下 URL 列入白名单 --

https://accounts.google.com/o/oauth2/auth
https://oauth2.googleapis.com/token
https://www.googleapis.com/oauth2/v1/certs
https://www.googleapis.com/robot/v1/metadata/x509/vf-grp-XXXXXXXXXXXappspot.gserviceaccount.com
https://www.googleapis.com/auth/cloud-platform

【问题讨论】:

标签: google-cloud-platform proxy gcloud service-accounts


【解决方案1】:

也许手动代理配置有效,但在使用自动检测时,您会收到一个不适用于 Gcloud URL 的 PAC 脚本。它也可能不适用于外壳/终端。

Gcloud 在您可以依赖的应用程序内部拥有自己的代理配置,因此您无需在操作系统中手动设置代理配置。

我必须设置以下值 (as documented):

gcloud config set proxy/type [PROXY_TYPE]
gcloud config set proxy/address [PROXY_IP_ADDRESS]
gcloud config set proxy/port [PROXY_PORT]

在我的情况下,因为我们还在代理上使用自定义 CA 证书,所以我还必须提取它们并将它们组合成一个可以在 Gcloud 中信任的证书。

gcloud config set core/custom_ca_certs_file [PATH_TO_CUSTOM_CA]

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    相关资源
    最近更新 更多