Deploying a Application Load Balancer Controller and Ingress Resource in Kubernetes Cluster.

 


Deploying a Application Load Balancer Controller and Ingress Resource in Kubernetes Cluster. 

In Kubernetes, an Ingress is an API object that manages external access to services within a cluster. It acts as a way to configure the routing of HTTP and HTTPS traffic from outside the cluster to services running within the cluster. In other words, an Ingress resource provides a set of rules that allow incoming traffic to reach the appropriate services based on the requested hostname, path, or other criteria.

Various Key Points To note about Ingress is that:- 

Routing Rules: Ingress resources define routing rules that specify how incoming requests should be forwarded to different services within the cluster. These rules can be based on hostnames, paths, or other request attributes.

Load Balancing: Ingress controllers often work in conjunction with load balancers to distribute incoming traffic across multiple instances of a service, improving availability and performance.

TLS Termination: Ingress resources can also handle SSL/TLS termination, allowing them to securely accept HTTPS traffic from the outside world and then forward it to the appropriate internal services using plain HTTP.

Sample Kubernetes Ingress yaml file:- 

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - host: example.com http: paths: - path: /app pathType: Prefix backend: service: name: app-service port: number: 80

Steps to Set up the AWS Load Balancer Controller and the Ingress Based resources in AWS EKS
cluster are: -

1. Create A 2 worker EKS cluster using AWS Console:-

Before We create A EKS Cluster in AWS we have create 2 IAM roles out of which one is for the Cluster role and other one is the Worker Node role.
For Creating the roles for Cluster and Worker nodes you can follow the Offical Documentation of AWS.






After Creating The Cluster You need to Create the worker nodes of the EKS cluster





With This your EKS cluster and The nodegroup are created. Now you have to login into the EKS cluster.
You can Login into the Cluster with the following command :- aws eks update-kubeconfig --region <region in your EKS cluster is deployed> -- name <Name of your EKS cluster>.

You Can verify that you have access of the cluster by using the following command:- kubectl get pods -n kube-system.


Now After This You need to create a OIDC provider for your Cluster. You Can create the OIDC provider for your cluster using the following command:-
eksctl utils associate-iam-oidc-provider --cluster $cluster_name --approve

Now To You need to create a AmazonEKSLoadBalancerControllerRole. For Creating this role you need The IAM POLICY which can downloaded for the following Links:-

For 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

For All other AWS Regions:-  curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json


After Creating the Policy You Need to Create a Role using The policy. while Creating the Role You need to select the Web-identity and then select the OIDC your EKS cluster in the choose a provider Section and Then Select the policy which is created using the previous command.




Then you have create a Service Account in your EKS cluster. Use the following code to create the aws-load-balancer-controller service account.

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/name: aws-load-balancer-controller
  name: aws-load-balancer-controller
  namespace: kube-system
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::511083883469:role/AmazonEKSLoadBalancerControllerRole

After Deploying The Service Account in EKS environment use the following three commands to deploy the LoadBalancer controller.

helm repo add eks https://aws.github.io/eks-charts
helm repo update eks
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=my-cluster \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller


You can check that the AWSLoadbalncerController is set perfectly in your EKS cluster using the following command.

kubectl get deployment -n kube-system aws-load-balancer-controller

The Output Should be as follows:-
NAME                    READY UP-TO-DATE AVAILABLE AGE aws-load-balancer-controller 2/2             2         2          84s


Then In order to add Domain and SSL certificate to it and you need to create a Route 53 Hosted zone and attach a ACM to it.



Now you are most welcome to create a ingress resource. I have attached example file to launch ingress resource in kubernetes cluster.




Thankyou.

Sibasish

I am a student pursuing Computer Science and Engineering at Silicon Institute of Technology. I am always eager to explore the world of computer Science and software development . Main areas of interest include Web-development, Machine Learning, and Cloud Computing.

Post a Comment

Previous Post Next Post