天天看點

GCP Windows配置SDK建立配置初始化配置配置GCP環境

建立配置

PS C:\Users\>gcloud config configurations create test-project

Created [test-project].

Activated [test-project].

切換到配置檔案

PS C:\Users\> gcloud config configurations activate test-project

初始化配置

PS C:\Users\> gcloud init

Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [test-project] are:

core:

  disable_usage_reporting: 'True'

Pick configuration to use:

 [1] Re-initialize this configuration [test-project] with new settings

 [2] Create a new configuration

 [3] Switch to and re-initialize existing configuration: [default]

 [4] Switch to and re-initialize existing configuration: [test-project]

這裡選擇1

Please enter your numeric choice:  1

Your current configuration has been set to: [test-project]

You can skip diagnostics next time by using the following flag:

  gcloud init --skip-diagnostics

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.

如果需要代理選擇Y,或者N

Do you have a network proxy you would like to set in gcloud (Y/n)?  y

Select the proxy type:

 [1] HTTP

 [2] HTTP_NO_TUNNEL

 [3] SOCKS4

 [4] SOCKS5

Please enter your numeric choice:  2

Enter the proxy host address: 你的代理位址

Enter the proxy port: 3128

Is your proxy authenticated (y/N)?  n

Cloud SDK proxy properties set.

Rechecking network connection...done.

ERROR: Reachability Check still does not pass.

    Cannot reach https://www.google.com (HTTPError)

Current effective Cloud SDK network proxy settings:

    type = http_no_tunnel

    host = test.com

    port = 3128

    username = None

    password = None

配置GCP環境

設定GCP的項目

PS C:\Users\>  gcloud config set test-project

設定GCP的地區

PS C:\Users\> gcloud config set compute/region asia-east2

Updated property [compute/region].

設定GCPzone

PS C:\Users\> gcloud config set compute/zone asia-east2-a

登陸你的GCP

PS C:\Users\> gcloud auth  [email protected]

4.檢視配置檔案

PS C:\Users\> gcloud config list

[compute]

region = asia-east2

zone = asia-east2-a

[core]

account =   [email protected]

disable_usage_reporting = True

project = test-project

[proxy]

address = test.com

port = 3128

type = http_no_tunnel

Your active configuration is: [test-project]