EKS using NLB ingress and multiple services deployed in node group

11/13/2020

So, I am very new to using EKS with NLB ingress and managing my own worker nodes using nodegroup (ASG). If I create a NLB ingress for the cluster and deploy multiple services inside the node group, how does NLB know that it has to load balance across service separately? Generally, when I have not used EKS and created by own k8s cluster, I have spun one NLB per service. Not sure how would it work in case of EKS with one NLB ingress for the whole cluster with multiple service inside. Or, do I need to create multiple NLBs somehow? Any help would be highly appreciated

-- Hary
amazon-eks
amazon-elb
amazon-web-services
aws-load-balancer
kubernetes

1 Answer

11/13/2020

when I have not used EKS and created by own k8s cluster, I have spun one NLB per service

AWS EKS is no different on this point. For a Network Load Balancer, NLB, e.g. on TCP/UDP level, you use a Kubernetes Service of type: LoadBalancer. But there are options, configured by the annotations on the Service. The most recent feature is IP mode. See EKS Network Load Balancing doc for more configuration alternatives.

Example:

kind: Service
apiVersion: v1
metadata:
  name: nlb-ip-svc
  annotations:
    # route traffic directly to pod IPs
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb-ip"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app: nginx

If I create a NLB ingress for the cluster and deploy multiple services inside the node group, how does NLB know that it has to load balance across service separately?

The load balancer uses the target pods that is matched by the selector: in your Service.

The alternative is to use an Application Load Balancer, ALB that is working on the HTTP/HTTPS level using the Kubernetes Ingress resources. The ALB requires an Ingress controller installed in the cluster and the controller for the ALB is recently updated, see AWS Load Balancer Controller

-- Jonas
Source: StackOverflow