Skip to main content
In this lab, we will walk through configuring an Ingress Controller, examining deployed resources, and updating Ingress paths to route traffic appropriately across multiple applications and namespaces.

Environment Overview

Begin by reviewing your cluster environment. Verify the nodes, namespaces, deployments, and pods. In this setup, there is one node with various namespaces hosting different components. For instance, run the following command to list all pods across all namespaces:
From the output, you can see pods running in several namespaces (such as app-space, ingress-nginx, and kube-system). The Ingress Controller is specifically deployed in the ingress-nginx namespace.

Ingress Controller Details

To verify the Ingress Controller deployment, execute the command below:
Notice that the Ingress Controller resource is named ingress-nginx-controller and operates within the ingress-nginx namespace.

Application and Ingress Resource

Applications are deployed within the app-space namespace. In our scenario, three application pods are running:
  • A default backend
  • A web application for video streaming
  • A web application for wear services
To view the Ingress resource, run:
The output will display an Ingress resource from the app-space namespace:
To gather more details, describe the Ingress resource:
The description reveals:
  • Two paths:
    /wear routes to wear-service on port 8080.
    /watch routes to video-service on port 8080.
  • A default backend (default-http-backend) is configured to handle unmatched requests.
  • The host is set to *, meaning the rules apply across all hosts.
A request made to the Ingress without a matching path results in a 404 error as the default backend is invoked. For example:
  • Accessing .../wear opens the wear application.
  • Accessing .../watch (which will later be changed to .../stream) serves the video streaming application.

Updating the Ingress Resource

Redirecting Video Streaming to “/stream”

To expose the video streaming application under the new URL path /stream:
  1. Edit the Ingress resource for the app-space namespace.
  2. Change the path from /watch to /stream.
Below is the updated Ingress YAML specification:
After applying these modifications:
  • Navigating to /watch now results in a 404 error.
  • Accessing /stream correctly displays the video streaming application.
After updating the Ingress resource, always verify the configuration using:
  • k get ingress -A
  • k describe ingress ingress-wear-watch -n app-space This ensures the new path registrations are active.

Adding a Path for the Food Delivery Application

The business has expanded by incorporating a food delivery service, now deployed in the app-space namespace. First, verify the deployments:
Example output:
Then, check the services:
Example output:
To expose the food delivery application, update the Ingress in the app-space namespace by adding an /eat path. For example:
Once applied:
  • Accessing .../eat displays the food delivery application.
  • All paths will be correctly routed to their respective services.

Integrating a New Payment Service in a Separate Namespace

A new critical payment service is deployed in its own namespace, critical-space. To verify the payment pods, run:
A sample output should include:
Now, check the payment deployment:
Example output:
Then, inspect the payment service details:
Example output:
Following best practices, each namespace should manage its own Ingress. Create a new Ingress resource in critical-space to expose the payment service at the /pay path. Use the imperative command:
Verify the new Ingress:
Expected output:
Describing the Ingress provides further details:
Output shows:
  • The rule routes /pay to pay-service on port 8282.
  • A default backend is present.
By default, the Ingress does not modify the URL path. If the payment application expects requests at / rather than /pay, add a rewrite annotation.
To add the path rewrite, update the payment Ingress with the following YAML:
After applying this change, requests to /pay will be rewritten to / before reaching the payment service, ensuring proper application functionality.

Conclusion

This lab demonstrated how to configure and update an Ingress Controller across multiple namespaces and applications. We:
  • Examined the cluster environment.
  • Verified and detailed the Ingress Controller deployment.
  • Updated the Ingress resource to change a URL path.
  • Added a new path for a food delivery application.
  • Created a separate Ingress for a critical payment service with proper path rewrite.
Each modification was verified by inspecting the Ingress resources and testing the endpoints to ensure a smooth transition.

Watch Video

Practice Lab