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 Answer
0
Accepted Answer

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
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions