Amazon Elastic Kubernetes Service (Amazon EKS) allows you to manage Kubernetes cluster. For each services, you may need to expose to the public Internet. In order to load the traffic between pods running the traffic, you can use AWS Load Balancer (ALB). In this tutorial, we will guide you how to redirect traffic from a Kubernetes EKS service to an Application load balancer (ALB).
AWS Load Balancer Controller is a controller to help manage Elastic Load Balancers for a Kubernetes cluster.
First, set the AWS Load Balancer Controller version:
echo 'export LBC_VERSION="v2.4.1"' >> ~/.bash_profile
echo 'export LBC_CHART_VERSION="1.4.1"' >> ~/.bash_profile
. ~/.bash_profile
Then check if the AWS Load Balancer Controller version has been set:
if [ ! -x ${LBC_VERSION} ]
then
tput setaf 2; echo '${LBC_VERSION} has been set.'
else
tput setaf 1;echo '${LBC_VERSION} has NOT been set.'
fi
Then, we need to create IAM OIDC provider
eksctl utils associate-iam-oidc-provider \\
--region <your aws region> \\
--cluster <your eks cluster> \\
--approve
We need to create IAM policy named AWSLoadBalancerControllerIAMPolicy
curl -o iam_policy.json <https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/${LBC_VERSION}/docs/install/iam_policy.json>
aws iam create-policy \\
--policy-name AWSLoadBalancerControllerIAMPolicy \\
--policy-document file://iam_policy.json
Now we create IAM role and ServiceAccount