Installing the AWS Load Balancer Controller add-on
Important
In versions 2.5 and newer, the AWS Load Balancer Controller becomes the default controller for Kubernetes
service resources with the type: LoadBalancer and
makes an AWS Network Load Balancer (NLB) for each service. It does this by making a mutating webhook
for services, which sets the spec.loadBalancerClass field to
service.k8s.aws/nlb for new services of type:
LoadBalancer. You can turn off this feature and revert to using the
legacy
Cloud ProviderenableServiceMutatorWebhook to false. The cluster won't
provision new Classic Load Balancers for your services unless you turn off this feature. Existing Classic Load Balancers
will continue to work.
The AWS Load Balancer Controller manages AWS Elastic Load Balancers for a Kubernetes cluster. The controller provisions the following resources:
- Kubernetes
Ingress -
The AWS Load Balancer Controller creates an AWS Application Load Balancer (ALB) when you create a Kubernetes
Ingress. - Kubernetes service of the
LoadBalancertype -
The AWS Load Balancer Controller creates an AWS Network Load Balancer (NLB) when you create a Kubernetes service of type
LoadBalancer. In the past, the Kubernetes network load balancer was used for instance targets, but the AWS Load balancer Controller was used for IP targets. With the AWS Load Balancer Controller version2.3.0or later, you can create NLBs using either target type. For more information about NLB target types, see Target type in the User Guide for Network Load Balancers.
The AWS Load Balancer Controller was formerly named the AWS ALB Ingress
Controller. It's an open-source
project
This topic describes how to install
the controller using default options. You can view the full documentation
Prerequisites
-
An existing Amazon EKS cluster. To deploy one, see Getting started with Amazon EKS.
-
An existing AWS Identity and Access Management (IAM) OpenID Connect (OIDC) provider for your cluster. To determine whether you already have one, or to create one, see Creating an IAM OIDC provider for your cluster.
-
Make sure that your Amazon VPC CNI plugin for Kubernetes,
kube-proxy, and CoreDNS add-ons are at the minimum versions listed in Service account tokens. -
Familiarity with AWS Elastic Load Balancing. For more information, see the Elastic Load Balancing User Guide.
To deploy the AWS Load Balancer Controller to an Amazon EKS cluster
In the following steps, replace the with your own values.example
values
-
Create an IAM policy.
-
Download an IAM policy for the AWS Load Balancer Controller that allows it to make calls to AWS APIs on your behalf.
-
AWS GovCloud (US-East) or AWS GovCloud (US-West) AWS Regions
$curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy_us-gov.json -
All other AWS Regions
$curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json
-
-
Create an IAM policy using the policy downloaded in the previous step. If you downloaded
iam_policy_us-gov.json, changeiam_policy.jsontoiam_policy_us-gov.jsonbefore running the command.$aws iam create-policy \ --policy-nameAWSLoadBalancerControllerIAMPolicy\ --policy-document file://iam_policy.jsonNote
If you view the policy in the AWS Management Console, the console shows warnings for the ELB service, but not for the ELB v2 service. This happens because some of the actions in the policy exist for ELB v2, but not for ELB. You can ignore the warnings for ELB.
-
-
Create an IAM role. Create a Kubernetes service account named
aws-load-balancer-controllerin thekube-systemnamespace for the AWS Load Balancer Controller and annotate the Kubernetes service account with the name of the IAM role.You can use
eksctlor the AWS CLI andkubectlto create the IAM role and Kubernetes service account. (Optional) Configure the AWS Security Token Service endpoint type used by your Kubernetes service account. For more information, see Configuring the AWS Security Token Service endpoint for a service account.
If you don't currently have the AWS ALB Ingress Controller for Kubernetes installed, or don't currently have the
0.1.xversion of the AWS Load Balancer Controller installed with Helm, then skip to the next step.Uninstall the AWS ALB Ingress Controller or
0.1.xversion of the AWS Load Balancer Controller (only if installed with Helm). Complete the procedure using the tool that you originally installed it with. The AWS Load Balancer Controller replaces the functionality of the AWS ALB Ingress Controller for Kubernetes.-
Install the AWS Load Balancer Controller using Helm V3 or later or by applying a Kubernetes manifest. If you want to deploy the controller on Fargate, use the Helm procedure. The Helm procedure doesn't depend on
cert-managerbecause it generates a self-signed certificate. -
Verify that the controller is installed.
$kubectl get deployment -n kube-system aws-load-balancer-controllerAn example output is as follows.
NAME READY UP-TO-DATE AVAILABLE AGE aws-load-balancer-controller 2/2 2 2 84sYou receive the previous output if you deployed using Helm. If you deployed using the Kubernetes manifest, you only have one replica.
-
Before using the controller to provision AWS resources, your cluster must meet specific requirements. For more information, see Application load balancing on Amazon EKS and Network load balancing on Amazon EKS.