Connect with us

Linux

How to setup Nginx ingress controller in AWS EKS Kubernetes Cluster

Last Updated on

Nginx ingress controller in AWS EKS
Source: https://www.nginx.com/products/nginx/kubernetes-ingress-controller/

In this tutorial, we are going to discuss how to set up the Nginx ingress controller in AWS EKS Kubernetes cluster using One elastic load balancer.

I,m assuming you are already set up the AWS EKS Kubernetes cluster and you can access the cluster using kubectl command.

Firstly, please download the below file and rename the file “kubernetes-ingress.txt” to “kubernetes-ingress.yaml”

this is the content of above file. No need to change anything.

You can apply it to Kubernetes using bellow command.

Create an SSL certificate in the AWS certificate manager.

Now you have to create an SSL certificate for your domain using AWS certificate manager.

you can create a new FREE SSL certificate which provides by AWS or you can use the existing one.

Please follow this AWS documentation to create the certificate or add the existing one to the AWS certificate manager.

After you created the certificate, go to the certificate details in the AWS certificate manager, and copy the ARN.

Please check the below screenshot. you will get an idea.

Nginx ingress controller

The Yellow part is the ARN. we need to add that ARN to the below file. I will explain that.

Create Nginx Ingress Service

Firstly, please download below file and rename the file “nginx-ingress-service.txt” to “nginx-ingress-service.yaml”

you can see this part in the above file

you have to replace “arn:aws:acm:us-east-1:475895322345:certificate/bf4d782b9-9dbc-4906-9e56-b4c7i7icead4b3” with your certificate ARN.

save the change and apply that service to the cluster by using bellow command.

Now please download the below file and rename the file “patch-configmap.txt” to “patch-configmap.yaml”

NOTE: no need to change this “proxy-real-ip-cidr: “0.0.0.0/0″”. you can change it if you want.

Apply that using the below command.

After that, you can check the Nginx ingress controller pod logs using kubectl logs command in the ingress-nginx namespace.

if everything is ok there will be no errors in the logs.

Now you can go to your AWS console and check the load balancers and you can see the magic happened there. 🙂

Kubernetes created a load balancer automatically there. you can point your domain DNS to ARN of that load balancer.

Ingress resources

Now you can create your ingress resources in any namespace.

The ingress controller which we created automatically points the load balancer to that ingress resource.

no need to touch anything related to the ingress controller now. you can do anything using ingress resources.

Ingress resource is just a file, like attached below.

I will add a sample ingress resource here. you can download it.

for the host, you can use a subdomain or main domain. it’s not an issue.

you can create multiple ingress resources for multiple subdomains.

Then you can apply it using kubectl apply command.

it will take a few mins to point the load balancer to it.

you can check it by using below command

if the load balancer pointed properly you can see the load balancer name under the ADDRESS column.

Ok guys this is enough for this tutorial.

I will discuss in the next article about multiple Nginx ingress controllers with multiple domains in one Kubernetes cluster.

If you have any questions, please comment below.

Cheers!!!

Continue Reading

Trending