Kubernetes Ingress Playlist - Part 3: Routing in the NGINX Ingress Controller

Learn about routing in Kubernetes with NGINX Ingress Controller, from basic routing to the use of regular expressions and canary deployments. Discover how to optimize access to multiple applications under a single IP with advanced traffic capabilities. Check examples and man

sábado, 16 de agosto de 2025 • 5 min read • Q2BSTUDIO Team

Artificial-Intelligence-

Kubernetes Ingress Playlist Part 3 Routing in NGINX Ingress Controller: in this installment we explain in a practical way how routing works with the NGINX Ingress controller using two simple Nodejs applications called simple-nodejs-app-1 and simple-nodejs-app-2 and we show the most useful routing patterns for production environments.

Introduction: Ingress is the Kubernetes resource that allows exposing HTTP and HTTPS services outside the cluster. The NGINX controller acts as a smart reverse proxy at the edge of the cluster, inspecting incoming requests and routing them to backend services according to rules based on host header path headers or custom conditions. With NGINX Ingress, access to multiple applications is centralized under a single IP or load balancer and capabilities such as TLS termination canary deployments authentication and advanced traffic policies are enabled.

Initial deployment: first we deploy the two applications in separate deployments each with its corresponding service. The deployment manifests can be applied with kubectl apply -f followed by the example URLs in the project repository. service-nodejs-app-1 listens on targetPort 8080 and service-nodejs-app-2 on targetPort 8081. Checking the services and pods allows verifying that both applications are ready and accessible from the Ingress.

1 Basic routing: in basic routing all incoming HTTP requests are directed to a single backend service. This pattern is ideal when the cluster hosts a single application or when a common frontend for all users is desired. Creating a simple Ingress resource pointing the root path to the service-nodejs-app-1 service and applying the manifest with kubectl apply -f nginx-ingress-basic-routing.yaml allows exposing the application through the load balancer DNS.

2 Path-based routing: path-based routing allows sending traffic to different services according to the URL path. For example the /app1 and /app2 routes can be mapped to service-nodejs-app-1 and service-nodejs-app-2 respectively. This is especially useful in microservices architectures to share a single domain and separate responsibilities by path. Applying a manifest like nginx-ingress-path-based-routing.yaml and configuring A records in DNS such as Route 53 pointing to the NLB allows testing http chinmayto.com slash app1 and http chinmayto.com slash app2.

3 Host-based routing: routing decisions can be based on the Host header allowing multiple applications to be served under different domains or subdomains. For example app1.chinmayto.com and app2.chinmayto.com can be mapped to different services. This pattern facilitates multi-tenancy and domain isolation while using a single Ingress controller. To set it up, an nginx-ingress-host-based-routing.yaml is created and A records for the subdomains pointing to the NLB are added.

4 Wildcard routing: wildcard rules allow matching multiple subdomains under a base domain with star patterns for example anything.chinmayto.com. It is ideal when subdomains are dynamically generated for users dashboards or other services and you do not want to declare each subdomain individually. Configuring an Ingress with host *.chinmayto.com and the wildcard DNS record in Route 53 simplifies subdomain management.

5 Routing with regular expressions: using regex in routes offers more powerful matching capabilities for complex or variable URL structures. By enabling the use regex option in annotations and using pathType ImplementationSpecific patterns such as slash app1 paren barra o fin paren punto punto can be defined to route to backends according to advanced rules. This approach allows handling dynamic routes but requires writing the expressions carefully and testing thoroughly.

6 Canary routing: canary routing facilitates progressive delivery by sending a percentage of traffic to a canary version of the application while the rest continues on the stable version. For example with a canary weight annotation at 20 percent a portion of traffic is redirected to service-nodejs-app-2 while the stable one remains on service-nodejs-app-1. This technique is key for safe deployments A B testing and risk mitigation in production.

Best practices and DNS: in real examples with AWS EKS the NGINX Ingress Controller is usually exposed through a Network Load Balancer NLB and DNS resolution is configured with A records in Route 53 pointing to the NLB. For TLS it is recommended to manage certificates using cert manager or ACM depending on the cloud platform. Monitoring logs and health checks are essential to maintain resilience and detect regressions in canary deployments or route changes.

About Q2BSTUDIO: Q2BSTUDIO is a software development company for custom applications and custom software specialized in enterprise solutions that integrate artificial intelligence and cybersecurity. We offer cloud services aws and azure business intelligence services and solutions with power bi to transform data into decisions. Our team designs AI agents and implements AI for companies that need to automate processes optimize operations and improve user experience. We also provide cybersecurity consulting to protect infrastructures and applications and develop custom applications with a focus on scalability performance and DevOps best practices.

Services we can contribute to your projects: design and implementation of Ingress and advanced load balancing in Kubernetes deployments on EKS or AKS TLS and certificate configuration CI CD pipeline integration migration to cloud services aws and azure custom software development development of artificial intelligence solutions and AI agents Power BI integration and business intelligence services cybersecurity audits and hardening and operational support for production environments.

Conclusion: mastering the routing capabilities of the NGINX Ingress Controller allows building secure and flexible Kubernetes platforms that support everything from monolithic applications to multi-domain microservices architectures and advanced deployments such as canary. If you need help designing implementing or maintaining these solutions Q2BSTUDIO can accompany you with practical experience in custom applications custom software artificial intelligence cybersecurity cloud services aws and azure business intelligence services AI agents and power bi.

Resources: for examples and complete manifests check the project repository on GitHub and if you want to start a collaboration with Q2BSTUDIO contact our team for consulting on architecture deployments and continuous delivery strategies.

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.