Clarifications on Kubernetes Ingress resource

9/30/2021

I am having below questions related to Ingress resource in Kubernetes

  1. Can a single Ingress controller (ex: NginxIngress Controller) be mapped to multiple Ingress resources?
  2. If the Ingress resources are mapped to single namespace, how to requested be routed in case of multiple ingress resources?
  3. Is the Ingress resource mapped to unique hostname?
  4. Is the ingress controller (ex: Nginx Ingress controller) bound to a namespace or is it a cluster level resource?
-- zilcuanu
kubernetes
nginx-ingress

1 Answer

10/1/2021
  1. Yes, it's possible, you can have a look here: https://stackoverflow.com/questions/65171303/is-it-possible-to-have-multiple-ingress-resources-with-a-single-gke-ingress-cont
  2. Considering ingress resources are ingress rules:

If you create an Ingress resource without any hosts defined in the rules, then any web traffic to the IP address of your Ingress controller can be matched without a name based virtual host being required.

For example, the following Ingress routes traffic requested for first.bar.com to service1, second.bar.com to service2, and any traffic to the IP address without a hostname defined in request (that is, without a request header being presented) to service3.

Name based virtual hosting

An optional host. In this example, no host is specified, so the rule applies to all inbound HTTP traffic through the IP address specified. If a host is provided (for example, foo.bar.com), the rules apply to that host.

Ingress rules

Parameters field has a scope and namespace field that can be used to reference a namespace-specific resource for configuration of an Ingress class. Scope field defaults to Cluster, meaning, the default is cluster-scoped resource. Setting Scope to Namespace and setting the Namespace field will reference a parameters resource in a specific namespace:

Namespace-scoped parameters avoid the need for a cluster-scoped CustomResourceDefinition for a parameters resource. This further avoids RBAC-related resources that would otherwise be required to grant permissions to cluster-scoped resources.

Namespace-scoped parameters

-- Jakub Siemaszko
Source: StackOverflow