Annotations in EKS services for creating network load balancers

1

I am trying to expose my kubernetes resources using a LoadBalancer service type. As such I have deployed the AWS Load Balancer Controller beforehand. Now when I create a LoadBalancer service, I see a Network Load Balancer getting created in AWS, which is just fine. But looking at the docs at https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html#network-load-balancer, its talking about adding the following annotations to the service resource

service.beta.kubernetes.io/aws-load-balancer-type: "external"
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "instance"

Now, this kind of seems redundant to me as I already have a Network Load Balancer with instance targets without adding any annotations to the k8s service. Thus, I am confused. Are the above annotations values just defaults? Do I need to provide these annotations mandatorily?

EDIT: I can see from https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/guide/service/annotations/#annotations that service.beta.kubernetes.io/aws-load-balancer-nlb-target-type has a default of instance but no defaults for service.beta.kubernetes.io/aws-load-balancer-type. So, that answers 1 part of my question.

1개 답변
0
수락된 답변

Hi Sayak,

To answer your question, let's see the history of why the annotation service.beta.kubernetes.io/aws-load-balancer-type: external came into being.

There are essentially two main Kubernetes controllers available to manage AWS Load Balancers instances:

  1. The legacy Kubernetes "Cloud Controller Manager", i.e. AWS cloud provider load balancer controller
  2. The new recommended "AWS Load Balancer Controller".

The legacy controller for aws until recently had it's code in the Kubernetes repository but I can see this commit which seems to have removed it (Looks like it is being packaged in v1.28.0-alpha.0 release).

The legacy controller used to create the Classic Load Balancers by default and then later fortified to also support Network Load Balancers. Later to support more customisations, the new recommended "AWS Load Balancer Controller" was introduced.

While both legacy cloud controller manager and aws load balancer controller were working together in the cluster, the annotation service.beta.kubernetes.io/aws-load-balancer-type: external was required. If the value of the annotation is set to external, the load balancer will be created by the new "AWS Load Balancer Controller".

So while not using the annotation service.beta.kubernetes.io/aws-load-balancer-type: external with other appropriate annotations will still create the Network Load Balancer for you but it will be created using the legacy AWS cloud provider load balancer controller and not the recommended "AWS Load Balancer Controller". The issues you will face is that the legacy provider is in deprecated mode and hence will not receive any new features and also it is due to be removed all together.

Hopefully, this answers your question.

profile picture
Manish
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠