liveBook · Manning

Ingress object

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

An Ingress is a Kubernetes API object that defines external HTTP or HTTPS routing rules to backend services.

An Ingress object defines how external HTTP or HTTPS requests reach Services inside a Kubernetes cluster. Its rules match request hostnames or paths; an ingress controller running in the cluster interprets those rules and forwards traffic. Create the backend Service first: an Ingress routes to a Service, not directly to a Deployment. section 6.3

To expose an application and verify the route:

  • Install an ingress controller and check that its controller pod is running with `kubectl -n ingress-nginx get all`. section 6.3
  • Create the workload and its Service: `kubectl create deploy hello --image nginxdemos/hello:plain-text --port 80`, then `kubectl expose deploy hello --name hello-svc --port 80`. Check both with `kubectl get deploy,svc`. section 6.3
  • Apply an Ingress rule for host `hello.com` and path `/`, with backend Service `hello-svc` on port 80. Check the declared host with `kubectl get ing`. section 6.3
  • Make `hello.com` resolve to the cluster endpoint, then run `curl hello.com` and check for the application's response. The hostname must resolve before the request can reach the controller. section 6.3
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: hello
spec:
  rules:
  - host: hello.com
    http:
      paths:
      - pathType: ImplementationSpecific
        path: "/"
        backend:
          service:
            name: hello-svc
            port:
              number: 80
  - host: app.hello.com
    http:
      paths:
      - pathType: Exact
        path: "/"
        backend:
          service:
            name: nginx
            port:
              number: 8080

Inspect the `networking.k8s.io/v1` manifest: each host rule contains a path, a `pathType`, and a Service name and port. Its second rule sends `app.hello.com` to a different Service, showing how one Ingress can route to multiple backends. section 6.3

Choose path matching deliberately: `Prefix` matches URL prefixes, while `Exact` matches the specified path string. If a request does not reach the intended application, check the controller, the Ingress host and path, the backend Service and port, and hostname resolution. section 6.3

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Works through controller installation, backend creation, an Ingress manifest and verification, without detailing controller internals or TLS configuration.
Examples
Uses a hello Deployment, a ClusterIP Service, host-based Ingress rules, `kubectl` status checks and a `curl` response.
What it assumes
Assumes an accessible Kubernetes cluster and basic Service knowledge; supplies commands to create and check the example backend.
What you can do after
Operate/configure it by creating an ingress controller and routing a named host to a Service, then verifying the response.
How it connects
Connects Services, Deployments, ingress controllers, DNS resolution and the Gateway API.

Also explained in

Compare how 8 books explain ingress object →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.