LoginSignup
2
1

EKSのnodegroupの設定を変更するときの話です。今まではeksctl createで新たなnodegroupを作成し、作成が確認できた後にeksctl deleteで古いnodegroupを削除する、という手段を取っていました。この方法だと、ClusterConfigのyamlファイルを2度修正する必要があり、少し手間がかかるな、と思っていました。

そんな時、EKSのコンソールにnodegroupに関する記述があるのを発見しました!
image.png




これをいじればいいのでは?と思いウキウキで編集を押した結果...
image.png
image.png
image.png
image.png

変更できるのは
・スケーリング設定
・Kubernetesラベル
・Kubernetesテイント
・タグ
・ノードグループの更新設定
の5つでした。

今回変更したかったのはワーカーノード作成時にアタッチされるロールが持つポリシーだったので、ここから変更することはできないようです。Taintの設定できるのが意外でした。



楽をすることをあきらめきれなかったのでコンソール画面を必死で探していると、起動テンプレートというものがあるのを発見しました。
image.png



しかしこちらは通常のEC2の起動テンプレートで設定できるものしか設定できませんでした。ロールを作成してポリシーをアタッチする機能は起動テンプレートにはない(はず)なのでこちらも撃沈です。

ただ、ユーザーデータはここから変更できることを確認しました!これはありがたい。
ありがたいとは思ったものの、ロールにアタッチするポリシーを変更したいという本来の目的は達成されていません。あきらめかけたその時、コンソールがダメならCLIを叩けばいいじゃない、というアイデアが湧いてきました。

いつもはeksctl createとeksctl deleteをしているのだから、既存のノードグループの設定を変更するeksctlコマンドがあってもいいんじゃなかろうか、と思い、コマンドを検索してみました

~$ eksctl --help
The official CLI for Amazon EKS

Usage: eksctl [command] [flags]

Commands:
  eksctl anywhere                        EKS anywhere
  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 deregister                      Deregister a non-EKS cluster
  eksctl disassociate                    Disassociate resources from a cluster
  eksctl drain                           Drain resource(s)
  eksctl enable                          Enable features in a cluster
  eksctl get                             Get resource(s)
  eksctl help                            Help about any command
  eksctl info                            Output the version of eksctl, kubectl and OS info
  eksctl register                        Register a non-EKS cluster
  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

Common flags:
  -C, --color string   toggle colorized logs (valid options: true, false, fabulous) (default "true")
  -d, --dumpLogs       dump logs to disk on failure if set to true
  -h, --help           help for this command
  -v, --verbose int    set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl [command] --help' for more information about a command.


For detailed docs go to https://eksctl.io/

するといかにもnodegroupの設定を更新できそうな2つのコマンドが見つかりました。

  eksctl update                          Update resource(s)
  eksctl upgrade                         Upgrade resource(s)

まずはupdateを深堀していきます。

~$ eksctl update --help
Update resource(s)

Usage: eksctl update [flags]

Commands:
  eksctl update addon                           Upgrade an Addon
  eksctl update cluster                         DEPRECATED: use 'upgrade cluster' instead. Upgrade control plane to the next version.
  eksctl update iamserviceaccount               Update an iamserviceaccount
  eksctl update nodegroup                       Update nodegroup

Common flags:
  -C, --color string   toggle colorized logs (valid options: true, false, fabulous) (default "true")
  -d, --dumpLogs       dump logs to disk on failure if set to true
  -h, --help           help for this command
  -v, --verbose int    set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl update [command] --help' for more information about a command.


For detailed docs go to https://eksctl.io/

nodegroup! いけそう!

~$ eksctl update nodegroup --help
Update nodegroup and its configuration.

                Please consult the eksctl documentation for more info on which config fields can be updated with this command.
                To upgrade a nodegroup, please use 'eksctl upgrade nodegroup' instead.
                Note that this is only available for managed nodegroups.

Usage: eksctl update nodegroup [flags]

General flags:
  -f, --config-file string   load configuration from a file (or stdin if set to '-')
      --timeout duration     maximum waiting time for any long-running operation (default 25m0s)
  -w, --wait                 wait for wait for update to finish before exiting

AWS client flags:
  -p, --profile string   AWS credentials profile to use (defaults to the value of the AWS_PROFILE environment variable)

Common flags:
  -C, --color string   toggle colorized logs (valid options: true, false, fabulous) (default "true")
  -d, --dumpLogs       dump logs to disk on failure if set to true
  -h, --help           help for this command
  -v, --verbose int    set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl update nodegroup [command] --help' for more information about a command.


For detailed docs go to https://eksctl.io/

よくわからんが、
・公式サイトを読め
・代わりにeksctl upgrade nodegroupを使え
と言ってそう

まず公式サイトを見てみる。

updateと検索してみるもeksctl updateに関して書いてある記事は見つからず...
更新できるフィールドが知りたかったが、自身の調査能力が足らず断念。

最後の望みをeksctl upgrade nodegroupに託す。



~$ eksctl upgrade nodegroup --help
Upgrade nodegroup

Usage: eksctl upgrade nodegroup [flags]

Nodegroup flags:
      --name string                      Nodegroup name
      --launch-template-version string   Launch template version
      --kubernetes-version string        Kubernetes version
      --force-upgrade                    Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue
      --release-version string           AMI version of the EKS optimized AMI to use
      --wait                             nodegroup upgrade to complete (default true)

General flags:
  -c, --cluster string     EKS cluster name
  -r, --region string      AWS region. Defaults to the value set in your AWS config (~/.aws/config)
      --timeout duration   maximum waiting time for any long-running operation (default 45m0s)

AWS client flags:
  -p, --profile string   AWS credentials profile to use (defaults to the value of the AWS_PROFILE environment variable)

Common flags:
  -C, --color string   toggle colorized logs (valid options: true, false, fabulous) (default "true")
  -d, --dumpLogs       dump logs to disk on failure if set to true
  -h, --help           help for this command
  -v, --verbose int    set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl upgrade nodegroup [command] --help' for more information about a command.


For detailed docs go to https://eksctl.io/

マニフェストファイルのmanagedNodeGroup.iam.attachPoilicyArnを変えることはできなさそう。



ということで、結局いつも通りの方法でアップデートすることにしました。

まとめ

nodegropuの更新は基本的にはeksctl createからのeksctl deleteで行わないといけない。
ただ、これでもしかしたらできるかも、という幻想を抱かなくて済むようになったので調べてよかった、と思うことにします。
また、公式ドキュメント調査力が足りていないことに気が付きました。AWSの一次ソースに触れることが多くなってきて調査力上がってる↑↑と思ってましたが、AWSの一次ソースに慣れていただけでした。まだまだ汎用的な力はついていないな、ということを認識できたのでもっとがむしゃらに資料を読み漁っていこうと思います。

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