How to Use Classic Load Balancer by Default in AWS EKS

Introduction

By default, Amazon EKS provisions a Network Load Balancer (NLB) when creating a LoadBalancer type service using the AWS Load Balancer Controller. However, if you need to use a Classic Load Balancer (CLB) instead, you must disable the default NLB behavior.

In this guide, I’ll show you how to configure EKS to use Classic Load Balancers by default.

Problem: Why is NLB Used by Default?

Starting from AWS Load Balancer Controller v2.5, Kubernetes services of type LoadBalancer automatically use an NLB. This happens due to the service mutator webhook, which sets:

1
2
spec:
loadBalancerClass: service.k8s.aws/nlb

By default, this webhook prevents the use of Classic Load Balancers (CLB). The solution? Disable the webhook!

How to Disable enableServiceMutatorWebhook

The AWS Load Balancer Controller allows you to disable the automatic NLB behavior by setting enableServiceMutatorWebhook=false.

If you installed the AWS Load Balancer Controller via Helm, run:

1
2
3
helm upgrade aws-load-balancer-controller eks/aws-load-balancer-controller \
--namespace kube-system \
--set enableServiceMutatorWebhook=false

Or if you are installing it for the first time:

1
2
3
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
--namespace kube-system \
--set enableServiceMutatorWebhook=false

This ensures that new services do not default to using an NLB.


Conclusion

By disabling the service mutator webhook in the AWS Load Balancer Controller, you can ensure that new Kubernetes services default to using Classic Load Balancers instead of NLBs.

If you need further automation, consider adding this configuration to your Helm charts or Infrastructure-as-Code (IaC) templates.