Exposing and Grouping Applications Using the AWS Load Balancer Controller on an Amazon EKS IPv4 Cluster
How to route external traffic to your Kubernetes services and manage Ingress resources using the AWS Load Balancer Controller on an IPv4-based cluster.
About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2023-08-30 |
- Install the latest version of kubectl. To check your version, run:
kubectl version --short
. - Install the latest version of eksctl. To check your version, run:
eksctl info
. - Install the latest version of Helm. To check your version, run:
helm version
.
- Authentication: Utilize the pre-configured IAM Role for Service Account (IRSA) for the AWS Load Balancer Controller (LBC) with the OpenID Connect (OIDC) endpoint, ensuring secure communication between Kubernetes pods and AWS services.
- AWS LBC Setup: Deploy the AWS Load Balancer Controller (LBC) on the Amazon EKS cluster, focusing on Custom Resource Definitions (CRDs) and the installation of the Load Balancer Controller itself.
- Sample Application Deployment: Build and expose the “2048 Game Sample Application” on port 80, defining routing rules and annotations for an internet-facing Application Load Balancer (ALB). Utilize custom annotations for the ALB, specifically the 'scheme' annotation and 'target-type' annotation, to instruct the AWS LBC to handle incoming HTTP traffic for IPv4-based clusters. For an Ingress Group, use the 'group.name' annotation to combine multiple Ingress resources under one ALB instance. To learn more, see Ingress annotations in the AWS LBC documentation.
Note that even if you're still within your initial 12-month AWS Free Tier period, the Application Load Balancer (ALB) falls outside the AWS free tier, hence usage could result in additional charges.
- First, confirm that you are operating within the correct cluster context. This ensures that any subsequent commands are sent to the intended Kubernetes cluster. You can verify the current context by executing the following command:
- Define the
CLUSTER_NAME
environment variable for your EKS cluster. Replace the sample value for clusterregion
.
- Define the
CLUSTER_REGION
environment variable for your EKS cluster. Replace the sample value for clusterregion
.
- Define the
CLUSTER_VPC
environment variable for your EKS cluster.
- Define the
ACCOUNT_ID
environment variable for the account associated with your EKS cluster.
- Use Helm to add the EKS chart repository to Helm.
- Update the repositories to ensure Helm is aware of the latest versions of the charts:
- Run the following Helm command to simultaneously install the Custom Resource Definitions (CRDs) and the main controller for the AWS Load Balancer Controller (LBC). To skip the CRD installation, pass the
--skip-crds
flag, which might be useful if the CRDs are already installed, if specific version compatibility is required, or in environments with strict access control and customization needs.
- Create a Kubernetes namespace called
game-2048
with the--save-config
flag.
- Deploy the 2048 game sample application.
- To retrieve the details of the Ingress resource, run the following command:
- Open a web browser and enter the ‘ADDRESS’ from the previous step to access the web application. For example,
k8s-game2048-ingress2-eb379a0f83-378466616.us-east-2.elb.amazonaws.com
. You should see the following 2048 game:
- Create a Kubernetes manifest called
updated-ingress-2048.yaml
and paste the following contents into it.
- Deploy the Kubernetes resources in
updated-ingress-2048.yaml
:
- To retrieve the details of the new Ingress resource, run the following command:
- Open a web browser and enter the "game-2048" ‘ADDRESS’ to access the web application. For example,
k8s-mygroup-d7adaa7af2-1349935440.us-east-2.elb.amazonaws.com
.
my-group
) using the 'group.name' annotation. To continue your journey by deploying a stateful workload, you need to set up data storage, such as the EBS CSI Driver or the EFS CSI Driver. These final installations will provide you with a robust, fully functional environment, ready for deploying your stateless and stateful applications.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.