amazon-web-servicesterraformaws-application-load-balancerterraform-provider-helm

How to create aws-load-balancer-controller on specific node in aws EKS


I'm trying to install aws-load-balancer-controller in my EKS cluster using terraform (resource "helm_release" "aws_load_balancer_controller").

I want the pod (pod/aws-load-balancer-controller-555d8dcf46-zz6tn) created in this process should be scheduled inside specific node.

I know that nodeSelector and nodeAffinity can be easily used, but I'm using terraform to create resources and not getting option to do so.

Any help would be appreciated.


Solution

  • In order to define the nodeSelector or affinity you have to use the values option [1] for the helm_release. So, in your case that would be something like:

    resource "helm_release" "aws_load_balancer_controller" {
      name       = "aws-load-balancer-controller"
      repository = "https://aws.github.io/eks-charts"
      chart      = "aws-load-balancer-controller"
      version    = "1.4.3"
    
      values = [
        file("${path.module}/values.yaml")
      ]
    }
    

    Then, you would have to create a values.yaml file in the same directory:

    nodeSelector:
      <label_key>: <label_value>
    

    where the <label_key> and <label_value> is the label key value pair for the Node you wish to run the Pod on.


    [1] https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#values