Ingress routing and TLS
Follow a bookstore request
The bookstore has three internal Services: frontend, inventory and health. A client wants one HTTPS address instead of three separate addresses. An Ingress describes routing rules so a compatible controller can configure a proxy or load balancer. The client connects to that infrastructure; it selects a Service backend using the request host and path. The Service then represents the application endpoints. An Ingress is an API object, not a running proxy. An implementation may forward directly to endpoints rather than literally through the Service virtual IP. A LoadBalancer Service exposes transport-level service access; Ingress adds HTTP routing semantics.
Client -> controller-managed HTTPS listener -> Service backend -> ready application endpointRead a complete routing declaration
This static manifest uses networking.k8s.io/v1. The fictional IngressClass offline-study and TLS Secret are deliberately absent from the lab environment; do not apply it. The three Services are defined in services.yaml in the same namespace. The backend port is the Service port 80, not the container targetPort 8080. ingressClassName identifies the IngressClass, which identifies the controller implementation. A class name alone does not install or start a controller.
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: shop namespace: shop-studyspec: ingressClassName: offline-study tls: - hosts: - shop.example.test secretName: shop-study-tls rules: - host: shop.example.test http: paths: - path: /api/health pathType: Exact backend: service: name: health port: number: 80 - path: /api pathType: Prefix backend: service: name: inventory port: number: 80 - path: / pathType: Prefix backend: service: name: frontend port: number: 80Predict path matches
Exact distinguishes /api/health from /api/health/. Prefix matches slash-separated path elements, not arbitrary string prefixes: /api matches /api/books but not /apiculture. Of matching paths in this Ingress, prefer the longest; if equally specific, Exact wins over Prefix. So /api/health goes to health, /api/books to inventory, and /apiculture to frontend. Host matching is independent; a different host has no matching rule in this fixture. A default backend or implementation-specific response may handle it. ImplementationSpecific paths depend on the controller; avoid them in portable examples. These examples assume ordinary case-sensitive, already parsed paths, not encoded or normalized variants.
shop.example.test /api/health -> health:80shop.example.test /api/books -> inventory:80shop.example.test /apiculture -> frontend:80other.example.test /api -> no match in this objectUnderstand TLS termination
The TLS host and Secret reference tell a compatible controller which certificate to serve. The Secret normally contains tls.crt and tls.key and belongs to the Ingress namespace. A client must trust the issuer, verify the hostname and check certificate validity. SNI helps select the certificate during the handshake, before the HTTP path is visible. Termination protects the client-to-proxy leg; backend encryption is a separate decision and often controller-specific for Ingress. Do not copy real keys into manifests or disable certificate checks. TLS does not itself enforce user authorization, and redirect from HTTP to HTTPS is not guaranteed by the tls field.
Diagnose without changing infrastructure
In an approved disposable lab, inspect the Ingress, class, associated controller, address, Service ports and endpoint readiness. Compare the intended route with an actual client request using a trusted lab CA and an authorized loopback listener. A missing address may indicate incomplete reconciliation or unavailable infrastructure; a certificate mismatch and a missing backend are distinct failures. Status is not proof of end-to-end success. The following commands are read-only against an explicitly approved lab; they are not executed here. Never use an unknown current context or expose a public listener just for testing.
kubectl --kubeconfig ./lab.kubeconfig --context route-study -n shop-study get ingress shop -o yamlkubectl --kubeconfig ./lab.kubeconfig --context route-study get ingressclass offline-studykubectl --kubeconfig ./lab.kubeconfig --context route-study -n shop-study get svc,endpointslicesPractice routing decisions
Read ingress.yaml and request-cases.json under lab-fixtures/gateway-routing. Predict the backend or no match for each case. Explain why a successful DNS lookup does not prove that the correct certificate or backend is available. The included Python checker models only the explicit host and path rules, not a real proxy.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Ingress routing and TLS — knowledge check
Interpret offline HTTP routing and migration evidence.
What makes an Ingress route traffic in practice?
Which backend handles /apiculture for the fixture host?
Which port is referenced by the Ingress backend?
What does an Ingress TLS Secret establish by itself?
If Exact and Prefix match equally long paths, which wins?