LoginSignup
3
0

More than 5 years have passed since last update.

金盾の内側から GCP を使う

Last updated at Posted at 2018-03-22

中国大陸から gcloud ツールを使うための方法。

準備

  • shadowsocks サーバー (壁の外に立てる)
  • ShadowsocksX
    • 127.0.0.1:1080 に SOCKS5 Proxy が立ち上がるようにする

image.png

gcloud コマンドを使えるようにする

gcloud config set proxy/** というコマンドがある。

Socks5 プロクシを通すので専用の設定を作成する。(プロクシなし設定と併用したいのであれば)

% gcloud config configurations create socks5
Created [socks5].
Activated [socks5].

gcloud init をする前に、プロクシ設定をする。

% gcloud config set proxy/address 127.0.0.1
Updated property [proxy/address].

% gcloud config set proxy/port 1080
Updated property [proxy/port].

% gcloud config set proxy/type socks5
Updated property [proxy/type].

プロクシ設定が終わったので、 init してみる。

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

Settings from your current configuration [socks5] are:
core:
  disable_usage_reporting: 'False'
proxy:
  address: 127.0.0.1
  port: '1080'
  type: socks5

Pick configuration to use:
 [1] Re-initialize this configuration [socks5] with new settings
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice:  1

Your current configuration has been set to: [socks5]

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.
Reachability Check passed.
Network diagnostic (1/1 checks) passed.

Choose the account you would like to use to perform operations for
this configuration:
 [1] xxxxxx@gmail.com
 [2] Log in with a new account
Please enter your numeric choice:  1

ログインできた。あとはいつも通り設定すれば OK

% gcloud compute --configuration socks5 ssh my-instance
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.13.0-1006-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

57 packages can be updated.
0 updates are security updates.


*** System restart required ***
Last login: Mon Mar  5 10:40:43 2018 from 203.212.41.213
shao@my-instance:~$

SSH もいける。

kubectl も使えるようにする

gcloud container clusters get-credentials --configuration socks5 --zone us-central1-a my-cluster

socks5 設定をしたプロファイルで kubectl の credential をとってくると、プロクシ設定もいっしょに引っ張ってくる模様。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0