Appearance

Ingress, Gateway API, and TLS

Route incoming HTTP requests by hostname and path, and trace where a TLS connection is decrypted.

What you will understand

  • Explain the relationship between an Ingress or Gateway API object and the controller that implements it.
  • Read a Gateway API route’s parent, hostname, path match, and Service reference.
  • Distinguish listener reachability, TLS certificate validation, and HTTP backend routing.

Builds on: NetworkPolicy and isolation

How incoming HTTP requests find a backend

A shop wants api.example.test/api to reach its API Service and www.example.test/ to reach the storefront. A routing rule can share one public address while sending requests to different backends. An Ingress declares HTTP routes and can reference TLS certificates. It needs an Ingress controller that implements those routes for the cluster. Applying a route object alone gives you an API record to inspect.

Gateway API splits this configuration across roles. A GatewayClass names the controller implementation. A Gateway configures one or more listeners, such as HTTPS on port 443. An HTTPRoute describes how requests reach a backend. A Gateway listener can control which routes it allows to attach. In the first scene, trace a route attachment from the route’s parent reference to a listener that accepts it.

Who owns each part of a Gateway route?

GatewayClass selects a controller, Gateway supplies a listener, and HTTPRoute attaches to a compatible listener to route requests.

  1. Select the GatewayClass

    GatewayClass names the controller responsible for realizing the Gateway. API objects alone do not install that controller.

  2. Configure the Gateway listener

    The Gateway declares listeners and which routes may attach, giving infrastructure a separate ownership boundary.

  3. Attach the HTTPRoute

    HTTPRoute parentRefs asks to attach to the Gateway. The controller checks listener rules and resolves backend references.

  4. Read the attachment conditions

    Status conditions describe attachment and references. Ready endpoints and external reachability are still needed for successful requests.

Gateway API CRDs and a compatible controller are already installed; all references are same-namespace.

Inspect YAML or commands

Report accepted configuration

kubectl describe httproute api
Explore another case

Attach a route to a Gateway

The HTTPRoute below refers to a Gateway named public and matches host api.example.test with path prefix /api. It forwards to port 80 on a Service named api. The Service may then forward to a different container port. To run the example, install the Gateway API definitions, use a compatible controller, and make sure the referenced Gateway, Service, and endpoints exist. The route status helps you see which parent accepted it and whether references resolved.

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: api
spec:
  parentRefs:
    - name: public
  hostnames:
    - api.example.test
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api
      backendRefs:
        - name: api
          port: 80        # Service port, not container targetPort.
kubectl get gatewayclass
kubectl get gateways,httproutes
kubectl describe httproute api
kubectl get service api
kubectl get endpointslices -l kubernetes.io/service-name=api
# Replace the address with the lab listener address, if installed.
curl -v -H 'Host: api.example.test' http://127.0.0.1:8080/api

A typical HTTPS listener presents a certificate for the requested hostname and terminates TLS by decrypting the connection there. It can then match the HTTP hostname and path. Whether the hop to the backend also uses encryption depends on the gateway and backend TLS configuration. The second scene shows the TLS and HTTP decisions in order.

What happens before an HTTPS request can be routed?

The gateway first establishes TLS with the client. After decrypting HTTP, it can choose a route and make its own backend connection.

  1. Gateway listenerLoad the certificate and key
    HTTPS listenerThe listener is ready to present its server identity.
  2. ClientVerify hostname and certificate trust
    GatewayThe TLS connection can be established.
  3. GatewayMatch the decrypted host and path
    HTTPRouteThe route identifies the corresponding backend Service.
  4. GatewayOpen the configured backend connection
    Backend ServiceUpstream encryption and identity are evaluated on this separate hop.
Follow the sequence

The gateway first establishes TLS with the client. After decrypting HTTP, it can choose a route and make its own backend connection.

HTTP routing after listener termination; passthrough TLS is intentionally outside this example.

Explore another case

Test hostname, path, and certificate

Use the curl command against the listener’s real address. With plain HTTP, the Host header lets you test hostname routing without adding a DNS record. With HTTPS, set the real hostname in the URL and use DNS or curl’s --resolve option to direct it to the test address. That also gives the TLS handshake and certificate check the correct hostname.

First verify a matching request, then change just its host or path. If routes attach but return a backend error, inspect the Service and ready endpoints. The networking lab builds the Service baseline. Route and certificate tests require the additional controller and listener described above.

Locate the failed stage of a request

A connection refusal can mean no listener is reachable. A certificate error occurs before an HTTP route can handle the request. A reachable gateway can still return an HTTP error for an unmatched route or unavailable backend. Check these stages in order to avoid editing routing rules to fix a TLS handshake.

Check your understanding

A browser reaches the HTTPS listener and rejects the certificate. Will changing the route’s path prefix fix that?

The client checks the certificate while setting up TLS. Verify that the listener presents a trusted certificate for the requested hostname, then retry so you can test HTTP path matching.

Primary documentation

Go to the source

Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise

Search the book

Search loads when you open it.

Keyboard shortcuts

Ctrl + K / ⌘ + K
Search the book
?
Open this guide
Tab / Shift + Tab
Move between controls
Enter / Space
Activate a focused button or disclosure
← / →
Focused visual timeline · previous or next step
Home / End
Focused visual timeline · first or last point
Esc
Close the open dialog or menu