Set Up An Application In AWS EKS with Network Load Balancer

First we need to Install EKS CTL

curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin

Then we need to create the EKS cluster by running this command

eksctl create cluster





aws eks update-kubeconfig --region ap-south-1 --name cluster1

oidc_id=$(aws eks describe-cluster --name wonderful-rainbow-1670691625 --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5)

aws iam list-open-id-connect-providers | grep $oidc_id

eksctl utils associate-iam-oidc-provider --cluster wonderful-rainbow-1670691625 --approve

curl -o iam_policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.4/docs/install/iam_policy.json


aws iam create-policy \
    --policy-name AWSLoadBalancerControllerIAMPolicy \
    --policy-document file://iam_policy.json


eksctl create iamserviceaccount \
  --cluster=wonderful-rainbow-1670691625 \
  --namespace=kube-system \
  --name=aws-load-balancer-controller \
  --role-name "AmazonEKSLoadBalancerControllerRole" \
  --attach-policy-arn=arn:aws:iam::111222233334444:policy/AWSLoadBalancerControllerIAMPolicy \
  --approve

sudo yum install openssl -y

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh


helm repo add eks https://aws.github.io/eks-charts

helm repo update


helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
  -n kube-system \
  --set clusterName=wonderful-rainbow-1670691625 \
  --set serviceAccount.create=false \
  --set serviceAccount.name=aws-load-balancer-controller 

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

kubectl create namespace nlb-sample-app

git clone https://github.com/redoyrahman02/nlb-sample-app.git

cd nlb-sample-app

kubectl apply -f sample-deployment.yaml

kubectl apply -f sample-service.yaml

kubectl get svc nlb-sample-service -n nlb-sample-app




Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply