<p>I have 1 deployment and 1 service configurations:</p>
<p><strong>Deployment</strong></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
    name: dashboard-backend-deployment
spec:
    replicas: 2
    selector:
        matchLabels:
            app: dashboard-backend
    template:
        metadata:
            labels:
                app: dashboard-backend
        spec:
            containers:
                - name: dashboard-backend
                  image: $BACKEND_IMAGE
                  imagePullPolicy: Always
                  env:
                      - name: NODE_ENV
                        value: $NODE_ENV
                      - name: PORT
                        value: '3000'
                      - name: ACCESS_TOKEN_JWT_KEY
                        value: $ACCESS_TOKEN_JWT_KEY
                      - name: REFRESH_TOKEN_JWT_KEY
                        value: $REFRESH_TOKEN_JWT_KEY
                      - name: GOOGLE_OAUTH_CLIENT_ID
                        value: $GOOGLE_OAUTH_CLIENT_ID
                      - name: GOOGLE_OAUTH_CLIENT_SECRET
                        value: $GOOGLE_OAUTH_CLIENT_SECRET
                      - name: GOOGLE_OAUTH_REDIRECT_URI
                        value: $GOOGLE_OAUTH_REDIRECT_URI
                      - name: GH_OAUTH_CLIENT_ID
                        value: $GH_OAUTH_CLIENT_ID
                      - name: GH_OAUTH_CLIENT_SECRET
                        value: $GH_OAUTH_CLIENT_SECRET
                      - name: GITHUB_OAUTH_REDIRECT_URI
                        value: $GITHUB_OAUTH_REDIRECT_URI
                      - name: MIXPANEL_TOKEN
                        value: $MIXPANEL_TOKEN
                      - name: FRONTEND_URL
                        value: $FRONTEND_URL
                      - name: CLI_TOKEN_JWT_KEY
                        value: $CLI_TOKEN_JWT_KEY
                      - name: DATABASE_URL
                        value: $DATABASE_URL
</code></pre>
<p><strong>Service</strong></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
    name: backend-service
    annotations:
        service.beta.kubernetes.io/aws-load-balancer-ssl-cert: $SSL_CERTIFICATE_ARN
        service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
        service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
spec:
    selector:
        app: dashboard-backend
    type: LoadBalancer
    ports:
        - name: https
          protocol: TCP
          port: 3000
          targetPort: 3000
</code></pre>
<p>I have a cluster, AWS EKS, configured. I run this command:
<code>kubectl apply -f=./k8s/backend-deployment.yaml -f=./k8s/backend-service.yaml</code>, of course, when <code>kubectl</code> is &quot;connected&quot; to my AWS EKS cluster.</p>
<p>Output of command:</p>
<pre><code>Using kubectl version: Client Version: v1.26.0
Kustomize Version: v4.5.7
Using aws-iam-authenticator version: {&quot;Version&quot;:&quot;0.6.2&quot;,&quot;Commit&quot;:&quot;...&quot;}
deployment.apps/dashboard-backend-deployment unchanged
service/backend-service unchanged
</code></pre>
<p>When I enter the load balancers section in <code>EC2</code> service in AWS, there are no load balancers at all. Why?</p>
<p>These are the Terraform files, I used to deploy my cluster:</p>
<p><strong>eks-cluster</strong>:</p>
<pre><code>data &quot;aws_iam_policy_document&quot; &quot;eks_cluster_policy&quot; {
  version = &quot;2012-10-17&quot;

  statement {
    actions = [&quot;sts:AssumeRole&quot;]
    effect  = &quot;Allow&quot;

    principals {
      type        = &quot;Service&quot;
      identifiers = [&quot;eks.amazonaws.com&quot;]
    }
  }
}

resource &quot;aws_iam_role&quot; &quot;cluster&quot; {
  name               = &quot;${var.project}-Cluster-Role&quot;
  assume_role_policy = data.aws_iam_policy_document.eks_cluster_policy.json

  tags = merge(
    var.tags,
    {
      Stack = &quot;backend&quot;
      Name  = &quot;${var.project}-eks-cluster-iam-role&quot;,
    }
  )
}

resource &quot;aws_iam_role_policy_attachment&quot; &quot;cluster_AmazonEKSClusterPolicy&quot; {
  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEKSClusterPolicy&quot;
  role       = aws_iam_role.cluster.name
}

resource &quot;aws_eks_cluster&quot; &quot;main&quot; {
  name     = &quot;${var.project}-cluster&quot;
  role_arn = aws_iam_role.cluster.arn
  version  = &quot;1.24&quot;

  vpc_config {
    subnet_ids              = flatten([aws_subnet.public[*].id, aws_subnet.private[*].id])
    endpoint_private_access = true
    endpoint_public_access  = true
    public_access_cidrs     = [&quot;0.0.0.0/0&quot;]
  }

  tags = merge(
    var.tags,
    {
      Stack = &quot;backend&quot;
      Name  = &quot;${var.project}-eks-cluster&quot;,
    }
  )

  depends_on = [
    aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy
  ]
}

resource &quot;aws_security_group&quot; &quot;eks_cluster&quot; {
  name        = &quot;${var.project}-cluster-sg&quot;
  description = &quot;Cluster communication with worker nodes&quot;
  vpc_id      = aws_vpc.main.id

  tags = merge(
    var.tags,
    {
      Stack = &quot;backend&quot;
      Name  = &quot;${var.project}-cluster-sg&quot;
    }
  )
}

resource &quot;aws_security_group_rule&quot; &quot;cluster_inbound&quot; {
  description              = &quot;Allow worker nodes to communicate with the cluster API Server&quot;
  from_port                = 443
  protocol                 = &quot;tcp&quot;
  security_group_id        = aws_security_group.eks_cluster.id
  source_security_group_id = aws_security_group.eks_nodes.id
  to_port                  = 443
  type                     = &quot;ingress&quot;
}

resource &quot;aws_security_group_rule&quot; &quot;cluster_outbound&quot; {
  description              = &quot;Allow cluster API Server to communicate with the worker nodes&quot;
  from_port                = 1024
  protocol                 = &quot;tcp&quot;
  security_group_id        = aws_security_group.eks_cluster.id
  source_security_group_id = aws_security_group.eks_nodes.id
  to_port                  = 65535
  type                     = &quot;egress&quot;
}
</code></pre>
<p><strong>EKS WORKER NODES</strong></p>
<pre><code>data &quot;aws_iam_policy_document&quot; &quot;eks_node_policy&quot; {
  version = &quot;2012-10-17&quot;

  statement {
    actions = [&quot;sts:AssumeRole&quot;]
    effect  = &quot;Allow&quot;

    principals {
      type        = &quot;Service&quot;
      identifiers = [&quot;ec2.amazonaws.com&quot;]
    }
  }
}

resource &quot;aws_iam_role&quot; &quot;node&quot; {
  name               = &quot;${var.project}-Worker-Role&quot;
  assume_role_policy = data.aws_iam_policy_document.eks_node_policy.json

  tags = merge(
    var.tags,
    {
      Stack = &quot;backend&quot;
      Name  = &quot;${var.project}-eks-node-iam-role&quot;,
    }
  )
}

resource &quot;aws_iam_role_policy_attachment&quot; &quot;node_AmazonEKSWorkerNodePolicy&quot; {
  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy&quot;
  role       = aws_iam_role.node.name
}

resource &quot;aws_iam_role_policy_attachment&quot; &quot;node_AmazonEKS_CNI_Policy&quot; {
  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy&quot;
  role       = aws_iam_role.node.name
}

resource &quot;aws_iam_role_policy_attachment&quot; &quot;node_AmazonEC2ContainerRegistryReadOnly&quot; {
  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly&quot;
  role       = aws_iam_role.node.name
}

resource &quot;aws_eks_node_group&quot; &quot;main&quot; {
  cluster_name    = aws_eks_cluster.main.name
  node_group_name = var.project
  node_role_arn   = aws_iam_role.node.arn
  subnet_ids      = aws_subnet.private[*].id

  scaling_config {
    desired_size = 1
    max_size     = 2
    min_size     = 1
  }

  ami_type       = &quot;AL2_x86_64&quot;
  capacity_type  = &quot;ON_DEMAND&quot;
  disk_size      = 20
  instance_types = [&quot;t3.small&quot;]

  tags = merge(
    var.tags,
    {
      Stack = &quot;backend&quot;
      Name  = &quot;${var.project}-eks-node-group&quot;,
    }
  )

  depends_on = [
    aws_iam_role_policy_attachment.node_AmazonEKSWorkerNodePolicy,
    aws_iam_role_policy_attachment.node_AmazonEKS_CNI_Policy,
    aws_iam_role_policy_attachment.node_AmazonEC2ContainerRegistryReadOnly,
  ]
}

resource &quot;aws_security_group&quot; &quot;eks_nodes&quot; {
  name        = &quot;${var.project}-node-sg&quot;
  description = &quot;Security group for all nodes in the cluster&quot;
  vpc_id      = aws_vpc.main.id

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = &quot;-1&quot;
    cidr_blocks = [&quot;0.0.0.0/0&quot;]
  }


  tags = merge(
    var.tags,
    {
      Stack                                          = &quot;backend&quot;
      Name                                           = &quot;${var.project}-node-sg&quot;
      &quot;kubernetes.io/cluster/${var.project}-cluster&quot; = &quot;owned&quot;
    }
  )
}

resource &quot;aws_security_group_rule&quot; &quot;nodes_internal&quot; {
  description              = &quot;Allow nodes to communicate with each other&quot;
  from_port                = 0
  protocol                 = &quot;-1&quot;
  security_group_id        = aws_security_group.eks_nodes.id
  source_security_group_id = aws_security_group.eks_nodes.id
  to_port                  = 65535
  type                     = &quot;ingress&quot;
}

resource &quot;aws_security_group_rule&quot; &quot;nodes_cluster_inbound&quot; {
  description              = &quot;Allow worker Kubelets and pods to receive communication from the cluster control plane&quot;
  from_port                = 1025
  protocol                 = &quot;tcp&quot;
  security_group_id        = aws_security_group.eks_nodes.id
  source_security_group_id = aws_security_group.eks_cluster.id
  to_port                  = 65535
  type                     = &quot;ingress&quot;
}

</code></pre>
<p><strong>VPC</strong></p>
<pre><code>resource &quot;aws_vpc&quot; &quot;main&quot; {
  cidr_block           = var.vpc_cidr
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = merge(
    var.tags,
    {
      Name                                           = &quot;${var.project}-vpc&quot;,
      &quot;kubernetes.io/cluster/${var.project}-cluster&quot; = &quot;shared&quot;
    }
  )
}

resource &quot;aws_subnet&quot; &quot;public&quot; {
  count             = var.availability_zones_count
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, count.index)
  availability_zone = data.aws_availability_zones.available.names[count.index]

  tags = merge(
    var.tags,
    {
      Name                                           = &quot;${var.project}-public-subnet&quot;,
      &quot;kubernetes.io/cluster/${var.project}-cluster&quot; = &quot;shared&quot;
      &quot;kubernetes.io/role/elb&quot;                       = 1
    }
  )

  map_public_ip_on_launch = true
}

resource &quot;aws_subnet&quot; &quot;private&quot; {
  count             = var.availability_zones_count
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, count.index + var.availability_zones_count)
  availability_zone = data.aws_availability_zones.available.names[count.index]

  tags = merge(
    var.tags,
    {
      Name                                           = &quot;${var.project}-private-sg&quot;
      &quot;kubernetes.io/cluster/${var.project}-cluster&quot; = &quot;shared&quot;
      &quot;kubernetes.io/role/internal-elb&quot;              = 1
    }
  )
}

resource &quot;aws_internet_gateway&quot; &quot;igw&quot; {
  vpc_id = aws_vpc.main.id

  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-igw&quot;,
    }
  )

  depends_on = [aws_vpc.main]
}

resource &quot;aws_route_table&quot; &quot;primary&quot; {
  vpc_id = aws_vpc.main.id

  route {
    cidr_block = &quot;0.0.0.0/0&quot;
    gateway_id = aws_internet_gateway.igw.id
  }

  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-primary-route-table&quot;,
    }
  )
}

resource &quot;aws_route_table_association&quot; &quot;internet_access&quot; {
  count          = var.availability_zones_count
  subnet_id      = aws_subnet.public[count.index].id
  route_table_id = aws_route_table.primary.id
}

resource &quot;aws_eip&quot; &quot;main&quot; {
  vpc = true

  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-ngw-ip&quot;
    }
  )
}

resource &quot;aws_nat_gateway&quot; &quot;main&quot; {
  allocation_id = aws_eip.main.id
  subnet_id     = aws_subnet.public[0].id


  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-ngw&quot;
    }
  )
}

resource &quot;aws_route&quot; &quot;main&quot; {
  route_table_id         = aws_vpc.main.default_route_table_id
  nat_gateway_id         = aws_nat_gateway.main.id
  destination_cidr_block = &quot;0.0.0.0/0&quot;
}

resource &quot;aws_security_group&quot; &quot;public_sg&quot; {
  name   = &quot;${var.project}-Public-sg&quot;
  vpc_id = aws_vpc.main.id


  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-Public-sg&quot;,
    }
  )
}

resource &quot;aws_security_group_rule&quot; &quot;sg_ingress_public_443&quot; {
  security_group_id = aws_security_group.public_sg.id
  type              = &quot;ingress&quot;
  from_port         = 443
  to_port           = 443
  protocol          = &quot;tcp&quot;
  cidr_blocks       = [&quot;0.0.0.0/0&quot;]
}

resource &quot;aws_security_group_rule&quot; &quot;sg_ingress_public_80&quot; {
  security_group_id = aws_security_group.public_sg.id
  type              = &quot;ingress&quot;
  from_port         = 80
  to_port           = 80
  protocol          = &quot;tcp&quot;
  cidr_blocks       = [&quot;0.0.0.0/0&quot;]
}

resource &quot;aws_security_group_rule&quot; &quot;sg_egress_public&quot; {
  security_group_id = aws_security_group.public_sg.id
  type              = &quot;egress&quot;
  from_port         = 0
  to_port           = 0
  protocol          = &quot;-1&quot;
  cidr_blocks       = [&quot;0.0.0.0/0&quot;]
}

resource &quot;aws_security_group&quot; &quot;data_plane_sg&quot; {
  name   = &quot;${var.project}-Worker-sg&quot;
  vpc_id = aws_vpc.main.id

  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-Worker-sg&quot;,
    }
  )
}

resource &quot;aws_security_group_rule&quot; &quot;nodes&quot; {
  description       = &quot;Allow nodes to communicate with each other&quot;
  security_group_id = aws_security_group.data_plane_sg.id
  type              = &quot;ingress&quot;
  from_port         = 0
  to_port           = 65535
  protocol          = &quot;-1&quot;
  cidr_blocks       = flatten([cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 0), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 1), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 2), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 3)])
}

resource &quot;aws_security_group_rule&quot; &quot;nodes_inbound&quot; {
  description       = &quot;Allow worker Kubelets and pods to receive communication from the cluster control plane&quot;
  security_group_id = aws_security_group.data_plane_sg.id
  type              = &quot;ingress&quot;
  from_port         = 1025
  to_port           = 65535
  protocol          = &quot;tcp&quot;
  cidr_blocks       = flatten([cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 2), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 3)])
}

resource &quot;aws_security_group_rule&quot; &quot;node_outbound&quot; {
  security_group_id = aws_security_group.data_plane_sg.id
  type              = &quot;egress&quot;
  from_port         = 0
  to_port           = 0
  protocol          = &quot;-1&quot;
  cidr_blocks       = [&quot;0.0.0.0/0&quot;]
}

resource &quot;aws_security_group&quot; &quot;control_plane_sg&quot; {
  name   = &quot;${var.project}-ControlPlane-sg&quot;
  vpc_id = aws_vpc.main.id

  tags = merge(
    var.tags,
    {
      Name = &quot;${var.project}-ControlPlane-sg&quot;,
    }
  )
}

resource &quot;aws_security_group_rule&quot; &quot;control_plane_inbound&quot; {
  security_group_id = aws_security_group.control_plane_sg.id
  type              = &quot;ingress&quot;
  from_port         = 0
  to_port           = 65535
  protocol          = &quot;tcp&quot;
  cidr_blocks       = flatten([cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 0), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 1), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 2), cidrsubnet(var.vpc_cidr, var.subnet_cidr_bits, 3)])
}

resource &quot;aws_security_group_rule&quot; &quot;control_plane_outbound&quot; {
  security_group_id = aws_security_group.control_plane_sg.id
  type              = &quot;egress&quot;
  from_port         = 0
  to_port           = 65535
  protocol          = &quot;-1&quot;
  cidr_blocks       = [&quot;0.0.0.0/0&quot;]
}
</code></pre>
<p>There are more files of course, but not sure they are relevant.</p>

Tal Rofe
<p>In order to create Loadbalancers automatically on the basis of service and ingress you need to deploy <a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/" rel="nofollow noreferrer"><code>aws-load-balancer-controller</code></a> in your EKS cluster.</p>
<p>AWS also has official documentation at <a href="https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html" rel="nofollow noreferrer">here</a>.</p>
<blockquote class="spoiler">
<p>! Disclaimer !! I have created the below-mentioned repo.</p>
</blockquote>
<p>You can also find terraform code to deploy and use the <code>aws-load-balancer-controller</code> in this <a href="https://github.com/ishuar/terraform-eks/tree/main/examples/cluster_with_alb" rel="nofollow noreferrer">ishuar/terraform-eks GitHub Repo</a> along with EKS module for practical referencing.</p>
