2 posts tagged with "eks"

View All Tags

Setting Up NGINX Ingress Controller in EKS with HTTP and TCP Routing

In AWS EKS, exposing each application with its own LoadBalancer is costly and inefficient. A smarter approach is using an NGINX Ingress Controller, which allows routing multiple applications through a single LoadBalancer — using host-based HTTP routing and TCP port-based routing.

This guide explains how to:

  • Deploy NGINX Ingress Controller via Helm
  • Set up host-based routing for HTTP apps
  • Configure TCP routing for non-HTTP services
  • Map domains via Cloudflare
  • Reference official docs

Why Use Ingress in EKS?#

Illustration of a confused man and woman surrounded by question marks, representing the question: Why Use Ingress in EKS?
Benefits
One LoadBalancer for many services
Lower costs
Host & path-based routing
Supports TCP & HTTP apps
Works with Cloudflare
Centralized config

Prerequisites#

  • EKS Cluster
  • Helm, kubectl, eksctl
  • Cloudflare account
  • Domain for your app
  • Applications/services already deployed in Kubernetes

Step 1: Install NGINX Ingress Controller via Helm#

Illustration of Person with wrench and gear symbolizing NGINX Ingress Controller installation via Helm
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx \
--create-namespace \
--namespace ingress-nginx \
--set controller.service.type=LoadBalancer

For advanced configurations, refer to the official NGINX Ingress Helm chart documentation.

This exposes the controller via a single ELB.


Step 2: Get ELB DNS for Ingress Controller#

kubectl get svc -n ingress-nginx

Note the external ELB DNS, e.g.:

a1b2c3d4e5f6g7.elb.amazonaws.com

Step 3: Set Up DNS in Cloudflare#

Person configuring website DNS settings on a large screen, representing DNS setup in Cloudflare
  1. Go to DNS settings
  2. Add a record:
    • Type: CNAME or A
    • Name: your-subdomain.yourdomain.com
    • Target: ELB DNS
    • Proxy status: DNS Only or Proxied

For Cloudflare-specific optimizations, check Cloudflare’s Kubernetes integration guide.


Step 4: HTTP Host-Based Ingress Example#

Here's a sample Ingress manifest:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pubggpiro9ypjn-ing
namespace: pubggpiro9ypjn
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: metube-app-622604.clb2.nifetency.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-f35714cd-4cb5-4f7e-b9db-4daa699640b3
port:
number: 8081

Apply the file:

kubectl apply -f ingress.yaml

Learn more about Ingress annotations in the Kubernetes Ingress documentation.


Step 5: Add TCP Support (Optional)#

Step 5.1: Create TCP ConfigMap#

apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
"5432": "my-namespace/postgres-service:5432"

Step 5.2: Upgrade Controller to Load TCP ConfigMap#

helm upgrade ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.extraArgs.tcp-services-configmap=ingress-nginx/tcp-services

Or during first install:

helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.extraArgs.tcp-services-configmap=ingress-nginx/tcp-services \
--set controller.service.type=LoadBalancer

For troubleshooting TCP routing, see NGINX’s TCP/UDP passthrough guide.


Step 6: Expose TCP Port in LoadBalancer#

Edit the controller service:

kubectl edit svc ingress-nginx-controller -n ingress-nginx

Add:

ports:
- name: postgres
port: 5432
targetPort: 5432
protocol: TCP

Routing Overview#

TypeUsesIngress Object?ConfigMap?DNS
HTTPWeb apps, APIsYesNoSubdomain
TCPPostgreSQL, RedisNoYesSame ELB + Port

Tips#

  • Use ingressClassName: nginx to prevent conflicts.
  • Use cert-manager for HTTPS/TLS termination.
  • Isolate apps using namespaces.
  • Annotate Ingress for rewrites, caching, rate-limiting, etc.

Conclusion#

With this setup, you can serve both HTTP and TCP apps in your EKS cluster using a single LoadBalancer, simplifying your architecture and saving costs. HTTP traffic is managed using Ingress resources with host rules, while TCP apps like databases are handled using a custom ConfigMap.

This architecture is production-ready when combined with Cloudflare for DNS, TLS, and protection.

For cluster management solutions, explore our Nife's Managed Clusters platform.

Discover solutions for Managing Multiple Organizations across your infrastructure

Host Multiple Services in EKS with One LoadBalancer Using NGINX Ingress and Cloudflare

When managing Kubernetes workloads on AWS EKS, using a LoadBalancer for each service can quickly become expensive and inefficient. A cleaner, scalable, and more cost-effective solution is to use an Ingress Controller like NGINX to expose multiple services via a single LoadBalancer. This blog will walk you through how I set up Ingress in my EKS cluster using Helm, configured host-based routing, and mapped domains through Cloudflare.


Prerequisites#

  • AWS EKS Cluster set up
  • kubectl, helm, and aws-cli configured
  • Services already running in EKS
  • Cloudflare account to manage DNS

Get started with EKS in the AWS EKS User Guide.


Step 1: Deploy NGINX Ingress Controller using Helm#

Illustration of the NGINX Ingress Controller Helm deployment process
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace \
--set controller.service.type=LoadBalancer

This will install the NGINX Ingress Controller and expose it through a LoadBalancer service. You can get the external ELB DNS using:

kubectl get svc -n ingress-nginx

Note the EXTERNAL-IP of the nginx-ingress-controller—this is your public ELB DNS.

Learn more about NGINX Ingress at the official Kubernetes documentation.


Step 2: Create Your Ingress YAML for Host-Based Routing#

Illustration of a group of people holding a banner representing Ingress YAML configuration for host-based routing

Below is an example Ingress manifest to expose a service using a custom domain:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pubggpiro9ypjn-ing
namespace: pubggpiro9ypjn
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: metube-app-622604.clb2.nifetency.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-f35714cd-4cb5-4f7e-b9db-4daa699640b3
port:
number: 8081

Apply the file using:

kubectl apply -f your-ingress.yaml

Step 3: Configure Domain in Cloudflare#

Illustration of Cloudflare DNS record configuration showing A and CNAME records for a domain.

Go to your Cloudflare dashboard and create a CNAME record:

  • Name: metube-app-622604 (or any subdomain you want)
  • Target: your NGINX LoadBalancer DNS (e.g., a1b2c3d4e5f6g7.elb.amazonaws.com)
  • Proxy status: Proxied ✅

Wait for DNS propagation (~1–5 minutes), and then your service will be available via the custom domain you configured.

Understand DNS management in Cloudflare with the Cloudflare DNS docs.


Verify the Setup#

Try accessing the domain in your browser:

http://metube-app-622604.clb2.nifetency.com

You should see the application running from port 8081 of the backend service.


Reference Document#

For more detailed steps and examples, check out this shared doc:
🔗 Ingress and DNS Setup Guide


Benefits of This Setup#

  • Cost-effective: One LoadBalancer for all services.
  • Scalable: Add new routes/domains by just updating the Ingress.
  • Secure: Easily integrate SSL with Cert-Manager or Cloudflare.
  • Customizable: Full control over routing, headers, and rewrites.

Conclusion#

Exposing multiple services in EKS using a single LoadBalancer with NGINX Ingress can streamline your infrastructure and reduce costs. Just remember:

  • Use Helm to install and manage the NGINX Ingress Controller
  • Configure host-based routing to serve multiple domains through one point
  • Use Cloudflare DNS to map custom domains to your LoadBalancer
  • Regularly test and validate access for each new service

With just a few commands and configurations, you can build a scalable and efficient ingress setup—ready for production.

Learn how to add and manage EKS clusters with Nife’s AWS EKS integration guide.

Learn how to add standalone Kubernetes clusters with Nife’s standalone cluster setup guide.