ludwig125のブログ

頑張りすぎずに頑張る父

GKEのチュートリアルでkubectlをインストールできなかった

cloud.google.com

こちらの方法に従ってkubectlをインストールしようとしたらエラーが出て失敗

gcloud components install kubectl
$ gcloud components install kubectl
 ERROR: (gcloud.components.install) 
You cannot perform this action because the Cloud SDK component manager 
is disabled for this installation. You can run the following command 
to achieve the same result for this installation: 

sudo apt-get install kubectl

sudo apt-get install kubectl も失敗した

$ sudo apt-get install kubectl
E: パッケージ 'kubectl ' にはインストール候補がありません

Kubernetes set-up on ubuntu on Google compute - Stack Overflow

ERROR: (gcloud.components.update) The component manager is disabled for this installation

It is a known issue on the Google Cloud SDK issue tracker : Issue 336: kubectl not installed by google-cloud-sdk debian package, and not installable

Unfortunately, it provides a poor experience for first timer testing kubernetes as it's hard to find a quick AND CLEAN step by step solution.

Here is one:

とあったので、以下のコマンドを逐次実行したことで解決した

sudo apt-get update
sudo apt-get remove google-cloud-sdk
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init
gcloud components list
gcloud components install kubectl
gcloud components list

注意:もともと入っているgcloud関連パッケージが消えてなくなるので、gcloud components listをして何が入っていたのかなど確認してから実行したほうがいい