0 votes
in Programming by (580 points)

I want to create a website on AWS infrastructure based on Elastic Kubernetes Service (EKS). The production pods (the pods that serve the website in production environment) are small enough to be able to run on t3.small EC2 instances. But the testing pods (the pods that run different kinds of tests) are really big and should be run on t3.xlarge EC2 instances.

I want my website to be up and running all the time. But I don't need the expensive t3.xlarge EC2 instances to be always running. I want them to be running only when they need to run tests. And when there is no need to run tests, I want them to get scaled down to zero nodes.

Is it possible to define two worker groups like this:

module "eks" {
  ...

  worker_groups = [
    {
      name          = "worker-group-1"
      instance_type = "t3.small"
      asg_max_size  = 10
      asg_desired_capacity = 1
      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"
        }
      ]
    },
    {
      name          = "worker-group-2"
      instance_type = "t3.xlarge"
      asg_max_size  = 10
      asg_desired_capacity = 0
      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"
        }
      ]
    },
  ]

}

So that worker-group-1 runs the pods in production environment and worker-group-2 runs the pods in testing environment.

Please note asg_desired_capacity = 0 in worker-group-2. Would it scale down the number of nodes to zero when there is no need to run tests?

Please log in or register to answer this question.

...