kubernetes

Kubernetes Ingress Explained: Routing External Traffic to Applications

Learn Kubernetes Ingress, Ingress Controllers, host and path routing, TLS, IngressClass, troubleshooting, best practices and real-world traffic flow.

By Shubhankar Tripathi • • 5 min read

Kubernetes Ingress Explained: Routing External Traffic to Applications

Kubernetes Ingress is a stable Kubernetes API for defining HTTP and HTTPS routing from outside a cluster to Services inside the cluster. It lets teams route requests by hostnames and URL paths, terminate TLS, and expose multiple applications through a shared external entry point. An Ingress resource is only the routing configuration; an Ingress controller must implement that configuration.

1. What Is Kubernetes Ingress?

A Kubernetes Ingress is an API object that defines rules for inbound HTTP and HTTPS traffic. The rules map requests to Kubernetes Services. The Service then provides the stable abstraction in front of the application's Pods.

Ingress is especially useful when several applications need to share an external entry point. Instead of exposing every application with a separate public load balancer, a controller can use host and path rules to route traffic to different Services.

Component

Primary responsibility

Client

Sends an HTTP or HTTPS request.

DNS

Resolves the application hostname to an externally reachable address.

Ingress controller / external proxy

Receives traffic and applies Ingress routing rules.

Ingress resource

Defines host, path, TLS and backend routing intent.

Service

Provides a stable endpoint for a set of Pods.

Pod

Runs the application that ultimately handles the request.

2. Ingress Is Not the Ingress Controller

This distinction is one of the most important concepts to understand.

  • Ingress resource: a Kubernetes API object containing routing rules.

  • Ingress controller: software that watches Ingress resources and configures or operates the traffic-handling data plane.

Creating an Ingress object by itself does not make an application reachable. A suitable Ingress controller must be installed and configured in the cluster.

Different controllers can have different features, annotations, TLS behavior, load-balancing capabilities, and operational characteristics. Always consult the documentation for the controller selected for your environment.

3. How Ingress Works

A typical request path looks like this:

  1. The user requests a hostname such as app.example.com.

  2. DNS resolves that hostname to the external address used by the ingress implementation.

  3. The client sends an HTTP or HTTPS request to that address.

  4. The Ingress controller receives the request.

  5. The controller evaluates the host and path against the Ingress rules.

  6. The selected backend Service is used as the application destination.

  7. The Service routes the request to an appropriate backend Pod.

  8. The application processes the request and the response travels back through the traffic path.

Client
  |
  | HTTP / HTTPS
  v
DNS -> External address
  |
  v
Ingress Controller / Load Balancer
  |
  | Host + Path routing
  v
Kubernetes Service
  |
  | Service dataplane
  v
Application Pods

4. Why Use Ingress?

Ingress becomes valuable when external HTTP(S) traffic must be routed to multiple applications or when centralized HTTP-level entry-point behavior is useful.

  • Host-based routing: different domains can reach different Services.

  • Path-based routing: different URL paths can reach different Services.

  • TLS termination: HTTPS can be terminated at the ingress point when supported by the controller.

  • Shared entry point: several applications can use the same external address.

  • Centralized routing intent: application routes can be represented as Kubernetes resources.

  • Load balancing: the controller can distribute traffic according to its implementation and configuration.

5. A Simple Ingress Resource

The current Ingress API is networking.k8s.io/v1. A minimal path-based example is:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-ingress
spec:
  ingressClassName: example
  rules:
  - host: example.com
    http:
      paths:
      - path: /shop
        pathType: Prefix
        backend:
          service:
            name: shop-service
            port:
              number: 80

The exact IngressClass name is environment-specific. Replace example with the class used by your installed controller.

6. Understanding Host-Based Routing

Host-based routing uses the HTTP Host header to select a backend. This allows multiple applications to share one external address while using different DNS names.

rules:
- host: shop.example.com
  http:
    paths:
    - path: /
      pathType: Prefix
      backend:
        service:
          name: shop-service
          port:
            number: 80

- host: api.example.com
  http:
    paths:
    - path: /
      pathType: Prefix
      backend:
        service:
          name: api-service
          port:
            number: 80

A request for https://shop.example.com can therefore be routed to shop-service, while a request for https://api.example.com can be routed to api-service.

7. Understanding Path-Based Routing

Path-based routing sends different URL paths to different Services.

rules:
- host: example.com
  http:
    paths:
    - path: /shop
      pathType: Prefix
      backend:
        service:
          name: shop-service
          port:
            number: 80

    - path: /api
      pathType: Prefix
      backend:
        service:
          name: api-service
          port:
            number: 8080

For example, /shop/products can be routed to shop-service while /api/orders can be routed to api-service. The precise path matching behavior is defined by the Ingress API and should not be confused with controller-specific URL rewriting features.

8. pathType: Prefix, Exact and ImplementationSpecific

pathType

Meaning

Example

Exact

Matches the complete path.

/login matches /login, not /login/

Prefix

Matches a path prefix according to the Ingress path matching rules.

/api matches /api and paths under that prefix

ImplementationSpecific

Matching behavior is determined by the IngressClass/controller.

Behavior depends on the selected controller

For portable manifests, prefer Exact or Prefix when they express the required behavior clearly. ImplementationSpecific should be used only when controller-specific behavior is intentional.

9. The IngressClass

A cluster may contain more than one Ingress controller. IngressClass identifies which controller should implement an Ingress.

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: example
spec:
  controller: example.com/ingress-controller

An Ingress can reference the class with ingressClassName:

spec:
  ingressClassName: example

A cluster can designate one IngressClass as the default. If an Ingress omits ingressClassName, default-class behavior depends on the cluster's IngressClass configuration.

10. TLS and HTTPS

Ingress can describe TLS configuration using a Secret containing a TLS certificate and private key. The standard Ingress API models TLS termination at the ingress point.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: secure-ingress
spec:
  ingressClassName: example
  tls:
  - hosts:
    - app.example.com
    secretName: app-example-tls
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app-service
            port:
              number: 80

The exact TLS capabilities and certificate-management workflow depend on the Ingress controller and surrounding platform. For example, certificate issuance and renewal are commonly handled by additional tooling rather than by the Ingress API itself.

The Kubernetes Ingress API supports TLS on port 443. The standard model assumes TLS termination at the ingress point; traffic from the ingress point to the Service and Pods may be plaintext unless the implementation is configured for encryption there as well.

11. Default Backend

An Ingress can define a default backend for requests that do not match the configured host/path rules.

spec:
  defaultBackend:
    service:
      name: default-service
      port:
        number: 80

Whether unmatched traffic reaches the configured default backend can also depend on the controller's behavior and configuration. Treat controller documentation as authoritative for implementation-specific details.

12. Wildcard Hostnames

Ingress supports wildcard host rules such as *.example.com. The wildcard covers a single DNS label.

  • api.example.com can match *.example.com.

  • shop.example.com can match *.example.com.

  • a.shop.example.com does not match *.example.com.

  • example.com itself does not match *.example.com.

13. Ingress and Kubernetes Services

Ingress normally routes to Services rather than directly selecting Pods. This separation is important because Pod IP addresses are not stable application endpoints.

Ingress
  |
  v
Service
  |
  +---- Pod A
  +---- Pod B
  +---- Pod C

The Service provides a stable abstraction while the Kubernetes networking layer maintains information about the Pods currently backing the Service. This makes application scaling and Pod replacement largely transparent to the Ingress routing configuration.

14. Ingress vs Service Type LoadBalancer

Capability

Ingress

Service type LoadBalancer

Primary protocol model

HTTP/HTTPS routing

Service exposure; commonly L4-oriented

Host-based routing

Yes

Not provided by the Service API itself

Path-based routing

Yes

Not provided by the Service API itself

TLS termination

Supported by Ingress/controller

Depends on the load-balancer implementation

Multiple applications behind one entry point

Common use case

Usually requires additional infrastructure

Non-HTTP protocols

Not the purpose of Ingress

Can be used for supported Service ports/protocols

Ingress and LoadBalancer Services are not simply interchangeable. Ingress is designed for protocol-aware HTTP/HTTPS routing, while a LoadBalancer Service exposes a Service externally using infrastructure supplied by the platform or cloud provider.

15. Ingress vs NodePort

Aspect

Ingress

NodePort

Routing level

HTTP/HTTPS

Service port exposure

Host/path rules

Supported

Not provided

Typical use

Web/API entry point

Directly expose a Service through node ports

External address

Provided by the controller/infrastructure

Uses node addresses and allocated node ports

16. Ingress vs Gateway API

This is an important current Kubernetes consideration: the Kubernetes project now recommends Gateway API for new development. The Ingress API is stable but frozen; the project does not plan to remove it, but new capabilities are being developed in Gateway API.

Topic

Ingress

Gateway API

Status

Stable API; frozen

Successor/future-oriented API family

Routing model

Ingress resource + controller

Gateway API resources such as Gateway and HTTPRoute

Design focus

Simple HTTP/HTTPS ingress routing

More expressive and role-oriented traffic management

Existing workloads

Widely deployed and supported

Migration may require conversion to Gateway API resources

For an existing platform that already uses Ingress, there is no requirement to immediately replace every Ingress resource. For new architecture decisions, evaluate Gateway API and the capabilities of the implementation you plan to use.

17. Common Production Architecture

                         Internet
                            |
                        DNS
                            |
                    External Load Balancer
                            |
                  Ingress Controller
                    /                                 /                         shop.example.com      api.example.com
                  |                    |
            shop-service          api-service
                  |                    |
              Pods x N             Pods x N

In a production platform, the external load balancer, ingress controller, TLS certificate management, DNS, Services, network policies, observability, and application health checks are separate concerns. Treating them as separate layers makes troubleshooting much easier.

18. What Happens When a Pod Is Replaced?

  1. A Deployment creates or replaces a Pod.

  2. The new Pod receives a new Pod IP.

  3. Readiness determines whether the Pod is considered ready for traffic.

  4. The Service's backend endpoint information is updated.

  5. The Ingress controller continues routing to the Service rather than depending on the old Pod IP.

This is one reason the Ingress → Service → Pod model is more robust than configuring an external proxy directly against individual Pod IP addresses.

19. Troubleshooting Ingress

When an application is unreachable, troubleshoot from the outside toward the backend instead of changing several layers at once.

  1. Check DNS resolution.

dig app.example.com
nslookup app.example.com

  1. Check the Ingress object.

kubectl get ingress -A
kubectl describe ingress web-ingress

  1. Check the selected IngressClass.

kubectl get ingressclass
kubectl describe ingressclass <class-name>

  1. Check the controller Pods and logs.

kubectl get pods -A
kubectl logs -n <controller-namespace> <controller-pod>

  1. Check the target Service.

kubectl get svc -n <namespace>
kubectl describe svc -n <namespace> <service-name>

  1. Check EndpointSlices.

kubectl get endpointslice -n <namespace>
kubectl describe endpointslice -n <namespace> <endpointslice-name>

  1. Check application readiness and Pod health.

kubectl get pods -n <namespace> -o wide
kubectl describe pod -n <namespace> <pod-name>

  1. Test the Service from inside the cluster.

kubectl run tmp-shell --rm -it --image=busybox:1.36 -- sh
wget -qO- http://<service-name>.<namespace>.svc.cluster.local

The exact debugging image and tools can vary by environment. The important method is to isolate DNS, external ingress, Service routing, and application health as separate layers.

20. Common Ingress Failure Scenarios

Symptom

Likely area

What to check

Ingress has no address

Controller / infrastructure

Controller status, events, external load balancer

404 or default backend

Host/path rule

Host header, path, pathType, default backend

502/503 from proxy

Backend

Service, EndpointSlices, Pod readiness, controller logs

TLS error

Certificate/TLS

Secret, hostname, certificate validity, controller TLS configuration

DNS does not resolve

DNS

Public DNS record and external address

Service has no endpoints

Service selector/readiness

Labels, selectors, Pod readiness, EndpointSlices

Ingress object exists but nothing happens

IngressClass/controller

ingressClassName, IngressClass, controller installation

21. Common Mistakes

  • Creating an Ingress resource without installing or configuring an Ingress controller.

  • Assuming Ingress can expose arbitrary TCP/UDP services.

  • Using the old ingress.class annotation when ingressClassName is appropriate.

  • Pointing an Ingress to a Service port that does not exist.

  • Using a Service selector that does not match the application Pods.

  • Assuming every Ingress controller supports the same annotations or advanced features.

  • Treating DNS problems as Kubernetes routing problems.

  • Putting aggressive liveness probes on an application that is temporarily slow during startup.

  • Assuming TLS at the ingress automatically encrypts traffic between every internal hop.

22. Best Practices

  • Explicitly choose and document the IngressClass used by the workload.

  • Keep host and path rules simple and readable.

  • Use Prefix or Exact path matching when possible for portable behavior.

  • Use readiness probes to prevent unready application Pods from receiving normal Service traffic.

  • Treat TLS certificates and private keys as sensitive Kubernetes Secrets and follow your platform's secret-management practices.

  • Document controller-specific annotations because they are not portable across all controllers.

  • Monitor controller health, request errors, latency, TLS failures and backend availability.

  • Use NetworkPolicy and other security controls separately from Ingress routing.

  • For new platforms, evaluate Gateway API because Kubernetes recommends it for future development.

  • Test routing rules with both matching and non-matching hosts and paths before production rollout.

23. Hands-On Lab: Host and Path Routing

The following lab demonstrates the Ingress resource structure. It assumes your Kubernetes environment already has an Ingress controller installed.

kubectl create deployment web --image=nginx
kubectl expose deployment web --port=80

kubectl create deployment api --image=nginx
kubectl expose deployment api --port=80

Create an Ingress manifest:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-ingress
spec:
  ingressClassName: <your-ingress-class>
  rules:
  - host: demo.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web
            port:
              number: 80
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: api
            port:
              number: 80

  1. Apply the manifest with kubectl apply -f ingress.yaml.

  2. Check kubectl get ingress and kubectl describe ingress demo-ingress.

  3. Determine the external address provided by your ingress implementation.

  4. Configure DNS or use an appropriate local test mechanism so demo.example.com resolves to that address.

  5. Test / and /api and confirm that the controller applies the expected routing rules.

In a real cluster, controller-specific behavior such as external address provisioning and local testing differs by environment. Follow the selected controller's installation and testing documentation.

24. Real-World Example: E-Commerce Platform

Consider an e-commerce platform with three workloads:

  • Frontend: shop.example.com/

  • Product API: shop.example.com/api/products

  • Order API: shop.example.com/api/orders

The platform can expose these workloads through a shared entry point while each application remains independently deployed behind its own Service. Scaling the product API from three Pods to ten Pods does not require changing the public hostname or the Ingress route.

25. Interview Questions

  • What is Kubernetes Ingress and why is an Ingress controller required?

  • What is the difference between an Ingress resource and an Ingress controller?

  • How does host-based routing work?

  • How does path-based routing work?

  • What is the purpose of ingressClassName?

  • What is the difference between Exact and Prefix path matching?

  • How does Ingress relate to a Kubernetes Service?

  • Can Ingress expose arbitrary TCP or UDP applications?

  • How is TLS configured in an Ingress resource?

  • Why can an Ingress return 502/503 even when the Ingress object exists?

  • How would you troubleshoot an Ingress with no external address?

  • What is the difference between Ingress and Service type LoadBalancer?

  • Why is Gateway API important for new Kubernetes networking designs?

  • How do readiness probes affect traffic reaching application Pods?

26. Production Checklist

  • Ingress controller installed and healthy

  • Correct IngressClass selected

  • DNS points to the correct external entry point

  • Host/path rules tested

  • Backend Services exist

  • Service selectors match intended Pods

  • EndpointSlices contain expected ready endpoints

  • Readiness probes are configured appropriately

  • TLS Secret and certificate are valid where HTTPS is required

  • Controller logs and metrics are monitored

  • Network and security policies are reviewed

  • Controller-specific configuration is documented

  • Gateway API evaluated for new platform designs

27. Key Takeaways

  • Ingress is a stable Kubernetes API for HTTP/HTTPS routing from outside the cluster to Services.

  • An Ingress resource defines routing intent; an Ingress controller implements it.

  • Host and path rules allow multiple applications to share an external entry point.

  • Ingress normally routes to Services, which provide stable application endpoints.

  • TLS can be configured at the ingress point, but exact behavior depends on the controller.

  • Ingress is not a general-purpose replacement for exposing arbitrary network protocols.

  • The Kubernetes project recommends Gateway API for new development because the Ingress API is frozen.

  • Troubleshooting should isolate DNS, ingress controller, routing rules, Service, EndpointSlices and Pod health.

28. Suggested Next Topics

  • Kubernetes Gateway API Explained: Gateway, HTTPRoute and Traffic Management

  • Kubernetes Service Explained: ClusterIP, NodePort and LoadBalancer

  • Kubernetes Service Discovery: How Pods Find Other Pods

  • Kubernetes DNS Explained: CoreDNS and Service Name Resolution

  • Kubernetes NetworkPolicy Explained: Controlling Pod Traffic

  • Kubernetes TLS and Certificate Management

  • Kubernetes Networking Architecture: Pod Network, Service Network and External Traffic

Official References

  • Kubernetes Documentation — Ingress: https://kubernetes.io/docs/concepts/services-networking/ingress/

  • Kubernetes Documentation — Ingress Controllers: https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/

  • Kubernetes API Reference — Ingress: https://kubernetes.io/docs/reference/kubernetes-api/networking/ingress-v1/

  • Kubernetes Documentation — Services, Load Balancing and Networking: https://kubernetes.io/docs/concepts/services-networking/

  • Kubernetes Documentation — Gateway API: https://kubernetes.io/docs/concepts/services-networking/gateway/