AWS - Introduced New Load Balancer Controller now can Share ALBs with multiple Kubernetes ingress rules
Vignesh Sivakumar
Cloud Architect | Transforming Businesses with Cloud-Native Solutions | GCP Expert | Migration, Automation, DevOps, MLOps & GenAI
Hello Guys, Long waiting update is here from AWS ALB !!!!!!!
Now we can share ALB with multiple Kubernetes Ingress ??
Application load balancing on Amazon EKS can load balance application traffic across pods using the ALB.
In the past, you needed to use a separate ALB for each application. The controller automatically provisions AWS ALBs in response to Kubernetes Ingress objects. It increases the cost of operating the infrastructure. After long waiting for the update, now You can share an ALB across multiple applications in your Kubernetes cluster using Ingress groups.ALBs can be used with pods deployed to nodes or to AWS Fargate. You can deploy an ALB to public or private subnets.
To share an ALB across multiple ingress resources using IngressGroups
alb.ingress.kubernetes.io/group.name: <my-group>
In this article, Will show you how to create a cluster and set up the new AWS Load Balancer Controller. The next article will deploy a sample application with multiple services with a single Application Load Balancer Controller as shown in the architecture below.
I will be using YAML to create the cluster and deploy the load balancer controller.
Create a file with the below code and save it as a cluster.yaml
apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: <my-cluster> region: <region-code> # traits of worker nodes nodeGroups: - name: ng-1 instanceType: t3.medium desiredCapacity: 3 minSize: 1 maxSize: 4 ssh: allow: true
Run the below command and create the cluster. It will take about 20 min+
eksctl create cluster -f cluster.yaml --kubeconfig kubeconfig
Create an IAM OIDC provider and associate it with your cluster.
eksctl utils associate-iam-oidc-provider \ --region <region-code> \ --cluster <my-cluster> \ --approve
Download an IAM policy for the AWS load balancer controller that allows it to make calls to AWS APIs on your behalf.
curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json
Create an IAM policy using the policy downloaded in the previous step.
aws iam create-policy \ --policy-name <AWSLoadBalancerControllerIAMPolicy> \ --policy-document file://iam-policy.json
Note: Copy ARN of the policy, we will need those next steps.
Create an IAM role and Kubernetes service account named aws-load-balancer-controller in the kube-system namespace, a cluster role, and a cluster role binding for the load balancer controller to use with the following command.
Replace the <ARN> with ARN copied above.
eksctl create iamserviceaccount \ --cluster=<my-cluster> \ --namespace=kube-system \ --name=aws-load-balancer-controller \ --attach-policy-arn= <ARN> \ --override-existing-serviceaccounts \ --approve
Install the TargetGroupBinding custom resource definitions.
kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master"
Install the AWS load balancer controller using Helm. Add the eks-charts repository.
helm repo add eks https://aws.github.io/eks-charts helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller \ --set clusterName=<cluster-name> \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller \ -n kube-system
Verify that the controller is installed.
kubectl get deployment -n kube-system aws-load-balancer-controller
Output:
NAME READY UP-TO-DATE AVAILABLE AGE aws-load-balancer-controller 1/1 1 1 8s
Congratulations. Now we have successfully installed and set up the New AWS Load Balancer Controller.
Now you can deploy your application on different service and you can use ingress group annotations to specify the group like below
alb.ingress.kubernetes.io/group.name: <my-group>
In next article will deploy a sample application with multiple services with a single Application Load Balancer Controller.
Reference:
https://aws.amazon.com/about-aws/whats-new/2020/10/introducing-aws-load-balancer-controller/
https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html
#thecloudnuggests #aws #alb #loadbalancer #loadbalancercontroller #eks #kubernetes