Skip to main content
In this lab, we explore setting up an Ingress Controller within a Kubernetes cluster and configuring it to route traffic to multiple applications across different namespaces. We will review the cluster environment, inspect namespaces and resources, and modify Ingress routes to suit evolving application requirements.
The image shows a terminal interface with a prompt and a task description about exploring an Ingress Controller setup in different namespaces.

Environment Overview

Begin by verifying the cluster nodes. In this setup, there is only one node present:
Next, check for deployments within the default namespace. The output shows no deployments:
Listing deployments across all namespaces reveals resources in app-space, ingress-nginx, and kube-system:

Verifying the Ingress Controller

Although Ingress Controllers are often deployed in the kube-system namespace, here it is installed in the ingress-nginx namespace. View all pods across namespaces with:
To confirm the Ingress Controller deployment in the ingress-nginx namespace, run:

Inspecting Applications and Ingress Resources in app-space

The applications reside in the app-space namespace. Listing pods demonstrates three deployed applications:
Now check the Ingress resource deployed in app-space:
Describing the Ingress resource gives further insights:
Key details from this configuration:
  • Requests to /wear are routed to the wear-service.
  • Requests to /watch are handled by the video-service.
  • Traffic not matching these paths is sent to the default-http-backend, resulting in a 404 error.
When accessing the Ingress’s external address, you initially see a 404 error. However, appending /watch or /wear to the URL correctly routes traffic to the respective applications.

Modifying Ingress Paths: Changing the Video Service Path

To change the video streaming endpoint from /watch to /stream, edit the Ingress resource in the app-space namespace. The original configuration is:
After editing, update the path so that the video service is available at /stream:
After applying this change, accessing the previous /watch route will now result in a 404 error, while navigating to /stream displays the video streaming application as expected.

Adding a New Path for the Food Delivery Application

A recently acquired food delivery application (webapp-food) is now running in the app-space namespace. Verify its deployment along with other applications:
Also review the corresponding services:
To expose the food delivery application at /eat, update the Ingress resource to include a new path:
After saving these changes, navigating to /eat will display the food delivery application.

Exposing a New Payment Service from a Separate Namespace

A critical payment service is deployed in a dedicated namespace called critical-space. Verify its deployment and service details:
It is recommended to create Ingress resources within the same namespace as the underlying application for better access control and management.
Create an Ingress to expose the payment service at /pay using the following imperative command:
After creation, check the Ingress:
A description of the Ingress reveals:
However, accessing /pay returns a 404 error because the Flask application is serving content only at the root URL /. Check the application logs to confirm:
To resolve this, add an annotation to rewrite the URL by removing the /pay prefix before forwarding requests to the backend. Update the Ingress resource as shown:
With this rewrite annotation, when accessing /pay, the prefix is stripped and the payment service receives the request at its root path. Verification via logs and browser confirms the service now responds correctly.
The image shows a tutorial on configuring Ingress for URL path forwarding in Kubernetes, explaining how to use rewrite-target options for proper routing to backend services.
This concludes the lab article on configuring Ingress for multiple applications across different namespaces, demonstrating best practices for routing and resource management in Kubernetes clusters.

Watch Video

Practice Lab