微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Spot 实例部署 EKS 集群时出错

如何解决使用 Spot 实例部署 EKS 集群时出错

所以我使用 terraform 模块来部署混合实例的 EKS 集群。这是有问题的模块,第三个示例是我需要做的:https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/spot-instances.md

我的代码

worker_groups_launch_template = [
{
  name                 = "linux-nodes"
  instance_type        = var.instance_type_l
  asg_min_size         = var.min_size
  asg_desired_capacity = var.desired_size
  asg_max_size         = var.max_size
  asg_recreate_on_change = true
  platform             = "linux"
  public_ip            = false
  root_encrypted       = true
  root_kms_key_id      = var.kms_key_arn
  on_demand_base_capacity = var.on_demand_base_capacity
  on_demand_percentage_above_base_capacity = var.on_demand_percentage_above_base_capacity
  spot_instance_pools  = var.spot_instance_pools

  kubelet_extra_args = "--node-labels=node.kubernetes.io/lifecycle=`curl -s http://169.254.169.254/latest/Meta-data/instance-life-cycle`"

  tags = [
    {
      "key"                 = "k8s.io/cluster-autoscaler/enabled"
      "propagate_at_launch" = "false"
      "value"               = "true"
    },{
      "key"                 = "k8s.io/cluster-autoscaler/${var.cluster_name}"
      "propagate_at_launch" = "false"
      "value"               = "true"
    },{
      "key"                 = "k8s.io/cluster-autoscaler/node-template/label/os"
      "value"               = "linux"
      "propagate_at_launch" = "true"
    }        
  ]
}]

我得到的错误

    Error: Invalid index
  on ../terraform-aws-eks/workers_launch_template.tf line 292,in resource "aws_launch_template" "workers_launch_template":
 292:     var.worker_groups[count.index],|----------------
    | count.index is 0
    | var.worker_groups is empty tuple
The given key does not identify an element in this collection value.

我不明白为什么它会抱怨 worker_groups,因为我使用的是 worker_groups_launch_template。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。