1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GKEメモ

Last updated at Posted at 2019-12-01

自分用のkubeアカウント、プロジェクト等の切り替え,GKE作成等のメモです。

大きな流れ

  • Authenticate with a service account on gcloud
  • Get credentials from a cluster through gcloud
  • Run any kubectl command that reaches the server

手順

serviceアカウントのactivate

gcloud auth activate-service-account [SERVICE_ACCOUNT_EMAIL] --key-file [KEY_FILE.JSON] --project [PROJECT_ID]
  • [SERVICE_ACCOUNT_EMAIL],[KEY_FILE.JSON]に関して

GCPコンソールから「IAMと管理」→「サービスアカウント」にて確認、生成できる。

clusterとの接続

gcloud container clusters get-credentials  [CLUSTER_NAME] --zone [ZONE]

### 接続できているかの確認

kubectl config get-contexts
  • context,container,accountの切り替え
gcloud auth list
gcloud config set account [ACCOUNT_ID]

gcloud projects list
gcloud config set project [PROJECT_ID]

// 補足、実行しなくても切り替えれそう。
gcloud container clusters get-credentials [CLUSTER_NAME] --zone [ZONE]

kubectl config get-contexts
kubectl config use-context [CONTEXT_NAME]

参照

https://github.com/kubernetes/kubernetes/issues/30617
https://cloud.google.com/sdk/gcloud/reference/auth/activate-service-account
https://qiita.com/hana_shin/items/b7a947511a89accea6d4

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?