2
2

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 5 years have passed since last update.

MacからGKEを操作するための認証メモ

Last updated at Posted at 2020-01-28

概要

  • 作業端末(Mac)からGKEにアクセスしたい
  • Macから認証情報を取得できなかった
  • CloudShellからは認証情報取得可能
  • 権限周りが問題と推測
  • コマンドは以下

詳細

Macの場合

$ gcloud container clusters get-credentials cluster-1 --zone asia-northeast1-a
Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get" permission(s) for "projects/[PROJECT_NAME]/zones/asia-northeast1-a/clusters/[CLUSTER_NAME]".

CloudShellの場合

$ gcloud container clusters get-credentials cluster-1 --zone asia-northeast1-a
Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.

原因

  • GoogleCloudSDKに認証をしていなかった

Google Cloud SDKの認証

$ gcloud auth login
Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?code_challenge=...
  • ここでユーザアカウント(Googleアカウント)かサービスアカウント(GCP用Googleアカウント)を選んで認証する必要がある
  • ここではサービスアカウントを選択
  • ユーザアカウントを選択してみたがgcloudコマンドによる認証は失敗した

image.png

  • 許可を押す

image.png

image.png

$ gcloud container clusters get-credentials cluster-1 --zone asia-northeast1-a
Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.

結論

  • MACからGKEを操作するにはまず”gcloud auth login”でCloudSDK認証をする事
  • その際はサービスアカウントでログインする必要がある(たぶん)

参考

公式:認証について

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?