The AWS Load Balancer Controller is a Kubernetes controller that manages AWS Elastic Load Balancers (ELBs) for a Kubernetes cluster running on Amazon EKS or self-managed Kubernetes on AWS. It automates the creation and management of Application Load Balancers (ALBs) and Network Load Balancers (NLBs) to route traffic to Kubernetes services.
In this lab, we will use AWS Application Load Balancer (ALB).
ssh ubuntu@18.206.88.146 -i ~/.ssh/labBastionHostSSHKey01.pem
18.206.88.146
to your EC2’s Public IP address.~/.ssh/labBastionHostSSHKey01.pem
to the path of the Key pair you downloaded when creating your EC2 instance.sudo su
.Run this code block.
# for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
# (Optional) Verify checksum
curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin
Confirm the installation with eksctl version
root@ip-10-0-1-234:~# eksctl version
0.190.0
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.7.2/docs/install/iam_policy.json
.aws iam create-policy \
--policy-name labAWSLoadBalancerControllerPolicy \
--policy-document file://iam_policy.json
root@ip-10-0-1-234:~# aws iam create-policy \
--policy-name labAWSLoadBalancerControllerPolicy \
--policy-document file://iam_policy.json
{
"Policy": {
"PolicyName": "labAWSLoadBalancerControllerPolicy",
"PolicyId": "ANPAQIJRSMTTDGFOSBY3W",
"Arn": "arn:aws:iam::017820706022:policy/labAWSLoadBalancerControllerPolicy",
"Path": "/",
"DefaultVersionId": "v1",
"AttachmentCount": 0,
"PermissionsBoundaryUsageCount": 0,
"IsAttachable": true,
"CreateDate": "2024-09-21T06:26:23+00:00",
"UpdateDate": "2024-09-21T06:26:23+00:00"
}
}
labEKSCluster01
to your’s cluster name.017820706022
to your account ID.eksctl create iamserviceaccount \
--cluster=labEKSCluster01 \
--namespace=kube-system \
--name=aws-load-balancer-controller \
--role-name labAWSLoadBalancerControllerRole \
--attach-policy-arn=arn:aws:iam::017820706022:policy/labAWSLoadBalancerControllerPolicy \
--approve
root@ip-10-0-1-234:~# kubectl -n kube-system get serviceaccount | grep aws-load-balancer-controller
aws-load-balancer-controller 0 81s
helm repo add eks https://aws.github.io/eks-charts
.helm repo update eks
.labEKSCluster01
to your’s cluster name.vpc-091882644e7c1e207
to your’s VPC ID.helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
-n kube-system \
--set clusterName=labEKSCluster01 \
--set serviceAccount.create=false \
--set serviceAccount.name=aws-load-balancer-controller \
--set region=us-east-1 \
--set vpcId=vpc-091882644e7c1e207
root@ip-10-0-1-234:~# helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
-n kube-system \
--set clusterName=labEKSCluster01 \
--set serviceAccount.create=false \
--set serviceAccount.name=aws-load-balancer-controller \
--set region=us-east-1 \
--set vpcId=vpc-091882644e7c1e207
NAME: aws-load-balancer-controller
LAST DEPLOYED: Sat Sep 21 06:49:02 2024
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
AWS Load Balancer controller installed!
root@ip-10-0-1-234:~# kubectl get deployment -n kube-system aws-load-balancer-controller
NAME READY UP-TO-DATE AVAILABLE AGE
aws-load-balancer-controller 2/2 2 2 58s
Next, we will deploy Wordpress application.