0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Terraformさん「最小キャパシティは希望キャパシティより大きくできません」ワイ「してるんだが?」

Last updated at Posted at 2026-01-05

はじめに

新人2年目SREエンジニアのデバッグ備忘録

nvalidParameterException: Minimum capacity 1 can't be greater than desired size 0

年末年始で起動用のオートスケーリング設定を削除した後、復活させようとした。
そのautoscaling groupをTerraformで適用しようとしたら、以下のようなエラーが出た。

╷
│ Error: updating EKS Node Group (welcome-study-eks-cluster:welcome_study_nodes-20251201090620580600000001) config: operation error EKS: UpdateNodegroupConfig, https response error StatusCode: 400, RequestID: 05870a2d-f7b4-4d79-a558-62f6959f22f8, InvalidParameterException: Minimum capacity 1 can't be greater than desired size 0
│ 
│   with module.eks.module.eks_managed_node_group["welcome_study_nodes"].aws_eks_node_group.this[0],
│   on .terraform/modules/eks/modules/eks-managed-node-group/main.tf line 447, in resource "aws_eks_node_group" "this":
│  447: resource "aws_eks_node_group" "this" {
│ 
╵

ちなみに、以下の起動用オートスケジューリングスケジュールを平日12:00ぐらいにapplyしようとしたンゴ

// 起動用
resource "aws_autoscaling_schedule" "start_schedule" {
  autoscaling_group_name = module.eks.eks_managed_node_groups_autoscaling_group_names[0]
  scheduled_action_name  = "start-schedule"
  start_time             = null
  end_time               = null
  desired_capacity       = 2
  min_size               = 1
  max_size               = 3
  time_zone              = "Asia/Tokyo"
  recurrence             = "0 9 * * 1-5" // 平日毎日09:00に起動
}

和訳すると

エラー:EKSノードグループ(ID: welcome-study-eks-cluster...)の設定更新中にエラーが発生しました。
EKSの操作「UpdateNodegroupConfig」に失敗しました(ステータスコード: 400)。
無効なパラメータ例外:最小キャパシティ「1」を、希望サイズ「0」より大きくすることはできません。

desired_capacity       = 2
min_size               = 1
max_size               = 3

希望キャパシティを2にしてるのに、なぜか0って判定されてる。
どうしよう。gemini助けて

EKSノードグループの基本設定を更新すればいいっぽい

どうやら、Terraformは現在の希望キャパシティの状態(夜間停止中の希望キャパシティ0)で定義通りに作ろうとするらしい。
つまり、Terraformが希望キャパシティはコード通りでない0(2を適用しようとしているけど)のままで作ろうとしていて、最小最大キャパシティはコード通りで作ろうとするらしい。
分かりづらいが、オートスケーリングスケジュールは関係なく、その前段のmanaged_node_groupだけ修正すればいい。
:::note
もしオートスケールで台数を増やしているなら、その状況に対して希望キャパシティが干渉してしまうとマズいという理屈らしい。つまり、Terraformの問題。というより正しい仕様って感じ。Terraformが私の酷いapplyを制御してくれていたみたい。
:::
module eksの以下が影響していて、terraformが希望キャパシティに関して干渉できないみたい
https://github.com/search?q=repo%3Aterraform-aws-modules%2Fterraform-aws-eks%20%20ignore_changes&type=code

解決法


そのため、対処法として現行のキャパシティをAWSコンソール側から変更するという強行手段をとった。

EKS -> cluster -> 該当のクラスターを選択 -> コンピューティング -> ノードグループ -> 編集

今回は研修用だし特にオートスケールされている状況ではないため、問題ない。
とにかく現状のノードグループの設定をいじらないとダメみたいですね。

夜間停止状態だった

desired_capacity       = 0
min_size               = 0
max_size               = 0

を元の設定である

  eks_managed_node_groups = {
    welcome_study_nodes = {
        min_size = 1
        desired_size = 2

に手動で変更した。
その後、起動用のTerraformをapplyしたら成功した。

最後に

TerraformもAWSもKubernetesも難しすぎでしょ。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?