LoginSignup
2

More than 5 years have passed since last update.

GKEでkubectlコマンドを使おうとしたら「ログインしてね」って怒られたときの謝り方

Last updated at Posted at 2017-06-12

Kubernetes で怒られた(´・ω・`)

GoogleContainerEngine(GKE)ちゃんと初めてのデートをしていました。途中で「Serviceの一覧を確認したほうがいいよ」と助言された(by参考資料)ので、次のコマンドを実行しました。

わたし
kubectl get services

ターンッ!!

Kubernetes
error: You must be logged in to the server (the server has asked for the client to provide credentials

おこらりた(´・ω・`)

どうやら、gcloud の設定が足りていなかったようです。

$ gcloud config set project PROJECT
$ gcloud config set compute/zone ZONE
$ gcloud config set container/cluster CLUSTER_NAME
$ gcloud container clusters get-credentials CLUSTER_NAME
  • PROJECT: Project ID
  • ZONE: Compute Engine ゾーン
  • CLUSTER_NAME: クラスターの名前(GKEダッシュボードから確認可能)

設定の確認

$ gcloud config list

これでKubernetesちゃんも機嫌をなおしてくれました!めでたしめでたし

参考

【kubectl】The connection to the server localhost:8080 was refused と叱られる
公式:(オプショナル) gcloud のデフォルトを設定

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