4
3

More than 5 years have passed since last update.

Amazon EKS で「aws eks update-kubeconfig」コマンドによる kubeconfig ファイルの自動設定がサポートされました

Posted at

はじめに

先月『Amazon EKS向けの「kubeconfig」設定ツールを作ってみた』という記事を書きましたが、AWS CLI で公式にサポートされた模様です。

Amazon EKS Simplifies Cluster Setup with update-kubeconfig CLI Command
https://aws.amazon.com/jp/about-aws/whats-new/2018/09/amazon-eks-simplifies-cluster-setup-with-update-kubeconfig-cli-command/

自作ツールは短い命でした。hideaki_aoyagi 先生の次回作にご期待下さい。

― 完 ―

公式コマンドを使ってみました

AWS CLI を最新版にアップデートして、早速コマンドを使ってみます。

$ pip install --upgrade --user awscli
$ aws --version
aws-cli/1.16.19 Python/3.6.5 Linux/4.14.62-65.117.amzn1.x86_64 botocore/1.12.9
$ aws eks update-kubeconfig --region us-west-2 --name eks-cluster
Added new context arn:aws:eks:us-west-2:123456789012:cluster/eks-cluster to /home/ec2-user/.kube/config
Warning: aws-iam-authenticator is not installed properly or is not in your path.
Refer to the AWS Documentation to download it at https://docs.aws.amazon.com/eks/latest/userguide/configure-kubectl.html

むむ? なんか警告が出ているようですが・・・

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: getting token: exec: exec: "aws-iam-authenticator": executable file not found in $PATH

やっぱりダメですね。

なんか「aws-iam-authenticator」が無い (またはパスが通っていない) って言われてます。

上記のようなエラーが出てしまった人は

Amazon EKSのリリース直後にEKSの設定を行った人は、もしかしたら私と同じようなエラーが出てしまうかもしれません。
逆に言うと、最近EKSの設定を行った人はたぶん問題ないと思います。

どういうことかと言うと、以前のEKSユーザーガイドの「Getting Started」の記述では、kubectlを使うために「heptio-authenticator-aws」というツールをインストールするように案内されていました。

ところが、その後「heptio-authenticator-aws」は「aws-iam-authenticator」と名前が変わり、ユーザーガイドの記述内容もそれに合わせて更新されています。

aws eks update-kubeconfig コマンドが生成する kubeconfig ファイルは、aws-iam-authenticator に依存する作りになっています。

という訳で、EKS設定時に「heptio-authenticator-aws」をインストールした人は、改めて「aws-iam-authenticator」をインストールしましょう。
(heptio-authenticator-aws は削除してもしなくてもOKです)

$ curl -LO https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
$ chmod +x ./aws-iam-authenticator
$ sudo mv ./aws-iam-authenticator /usr/local/bin/

これでエラーは出なくなります。
(aws eks update-kubeconfig コマンドを再実行する必要はありません)

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-28T20:13:43Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

おわりに

公式ドキュメントや GitHub の更新はこまめにチェックすべきですね。

4
3
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
4
3