12 Using Ingress to Route Traffic to Services

 

This chapter covers

  • Creating Ingress objects
  • Deploying and understanding Ingress controllers
  • Securing ingresses with TLS
  • Adding additional configuration to an Ingress
  • Using IngressClasses when multiple controllers are installed
  • Using Ingresses with non-service backends

In the previous chapter, you learned how to use the Service object to expose a group of pods at a stable IP address. If you use the LoadBalancer service type, the service is made available to clients outside the cluster through a load balancer. This approach is fine if you only need to expose a single service externally, but it becomes problematic with large numbers of services, since each service needs its own public IP address.

Fortunately, by exposing these services through an Ingress object instead, you only need a single IP address. Additionally, the Ingress provides other features such as HTTP authentication, cookie-based session affinity, URL rewriting, and others that Service objects can’t.

NOTE

12.1 Introducing Ingresses

Before I explain what an Ingress is in the context of Kubernetes, it may help readers for whom English isn’t their first language to define what the term ingress means.

Definition

Ingress (noun)—The act of going in or entering; the right to enter; a means or place of entering; entryway.

12.1.1 Introducing the Ingress object kind

12.1.2 Introducing the Ingress controller and the reverse proxy

12.1.3 Installing an ingress controller

12.2 Creating and using Ingress objects

12.2.1 Exposing a service through an Ingress

12.2.2 Path-based ingress traffic routing

12.2.3 Using multiple rules in an Ingress object

12.2.4 Setting the default backend

12.3 Configuring TLS for an Ingress

12.3.1 Configuring the Ingress for TLS passthrough

12.3.2 Terminating TLS at the ingress

12.4 Additional Ingress configuration options

12.4.1 Configuring the Ingress using annotations

12.4.2 Configuring the Ingress using additional API objects

12.5 Using multiple ingress controllers

12.5.1 Introducing the IngressClass object kind

12.5.2 Specifying the IngressClass in the Ingress object

12.5.3 Adding parameters to an IngressClass

12.6 Using custom resources instead of services as backends

12.6.1 Using a custom object to configure Ingress routing

12.7 Summary