「脆弱性の対応がされたからバージョンアップしておくか」
「新機能を使いたいからアップデートしようかな」
パッケージ管理(yum, apt など)をしていて、対象のモジュールを一気にアップデートする機会はあるかもしれませんが、通常、コマンドラインで利用するツールを更新する機会は限られます。
しかし稀に、エラーにはならなくても、依存関係が影響して想定通りの挙動にならないケースもあるようです。
そう、AWS の EKS を操作する「eksctl」コマンドです。
今回は eksctl をアップデートする方法を紹介します。
その後、eksctl のアップデートでハマったことがあったので、以下の記事に備忘録として残しておきました。

eksctlの新しいバージョンが推奨される理由
eksctl の詳細は以下で確認した方が確実なので、ここでは詳しい説明は省略します。
eksctl は、ECS でクラスターを作成するためのシンプルな CLI ツールです。これは、EC2 用の Amazon の新しいマネージド Kubernetes サービスです。 Go で記述され、CloudFormation を使用します。
この AWS の公式ドキュメントのページに記載があるように、eksctl は求められるバージョンが頻繁に上がっています。
(2021年6月現在、0.43.0 以上ですが、英語ページだと 0.51.0 になっています)
だからと言って、古いバージョンの eksctl が全く使えないわけではなく、ある程度の操作は問題なく実行できます。
そこが怖いのですけどね・・・。
実は EKS のアップグレードに伴う処理で少し問題に遭遇しました。
(特にノードの作成時)
eksctlのバージョンアップ
では、eksctl のバージョンアップ方法です。
まずはローカルのバージョンを確認してみます。
1 2 3 | $ eksctl version 0.30.0 |
これでは、AWS の日本語ページで推奨されているバージョンよりもかなり低いですね。
homebrew-coreのエラー
早速 brew でアップグレードしてみましたが、私の環境ではエラーが出てしまいました。
(エラーが出なかった人は「再度eksctlをアップグレード」まで読み飛ばしてください)
1 2 3 4 5 6 7 8 9 10 11 12 | $ brew upgrade eksctl Error: homebrew-core is a shallow clone. To `brew update`, first run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow This restriction has been made on GitHub's request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you automatically to avoid repeatedly performing an expensive unshallow operation in CI systems (which should instead be fixed to not use shallow clones). Sorry for the inconvenience! |
これは eksctl とは関係なく brew の問題のようですね。下記のサイトが参考になりました。
エラーに書かれている通り、以下のコマンドを実行してみましょう。
1 2 3 4 5 6 7 8 9 10 | $ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow remote: Enumerating objects: 790345, done. remote: Counting objects: 100% (790281/790281), done. remote: Compressing objects: 100% (261587/261587), done. remote: Total 780581 (delta 526998), reused 769612 (delta 516117), pack-reused 0 Receiving objects: 100% (780581/780581), 316.90 MiB | 9.16 MiB/s, done. Resolving deltas: 100% (526998/526998), completed with 7697 local objects. From https://github.com/Homebrew/homebrew-core c93214fd17..262ad8675d master -> origin/master |
再度eksctlをアップグレード
再度アップグレードを試します。
1 2 3 4 5 | $ brew upgrade eksctl ==> Upgrading 1 outdated package: weaveworks/tap/eksctl 0.30.0 -> 0.52.0 ==> Upgrading weaveworks/tap/eksctl 0.30.0 -> 0.52.0 |
バージョンを確認します。
1 2 3 | $ eksctl version 0.52.0 |
めでたし、めでたし。
主要なオプションもメモっておこう。
eksctl associate : Associate resources with a cluster
eksctl completion : Generates shell completion scripts for bash, zsh or fish
eksctl create : Create resource(s)
eksctl delete : Delete resource(s)
eksctl disassociate : Disassociate resources from a cluster
eksctl drain : Drain resource(s)
eksctl enable : Enable features in a cluster
eksctl generate : Generate gitops manifests
eksctl get : Get resource(s)
eksctl help : Help about any command
eksctl scale : Scale resources(s)
eksctl set : Set values
eksctl unset : Unset values
eksctl update : Update resource(s)
eksctl upgrade : Upgrade resource(s)
eksctl utils : Various utils
eksctl version : Output the version of eksctl
まとめ
eksctl のバージョンアップ方法を紹介してきました。
通常は brew upgrade でサクっと終わるのですが、頻繁に使わないコマンドでは予期せぬエラーに遭遇することがありますね・・・。
少し前に紹介した「Let’s Encrypt」の certbot がまさにそうでした。

また、eksctrl は AWS の EKS の操作に大きく影響するので、常に新しいバージョンを気にかけておきたいですね。