0
0
KubernetesConceptBeginner · 3 min read

What is Ingress in Kubernetes: Simple Explanation and Example

In Kubernetes, Ingress is a resource that manages external access to services inside a cluster, usually HTTP or HTTPS. It acts like a smart gatekeeper that routes incoming traffic to the right service based on rules like URL paths or hostnames.
⚙️

How It Works

Think of Ingress as a receptionist at the entrance of a large office building. When visitors arrive, the receptionist checks their request and directs them to the correct room or department. Similarly, Ingress receives incoming web traffic and routes it to the right service inside the Kubernetes cluster based on rules you define.

Behind the scenes, Ingress works with an Ingress Controller, which is a special program that listens for Ingress rules and configures the network to handle traffic accordingly. This setup allows you to manage multiple services under one IP address or domain, using paths or hostnames to separate them.

💻

Example

This example shows a simple Ingress resource that routes traffic to two different services based on the URL path.

yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
      - path: /app2
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80
Output
Ingress resource "example-ingress" created, routing example.com/app1 to app1-service and example.com/app2 to app2-service
🎯

When to Use

Use Ingress when you want to expose multiple Kubernetes services through a single external IP or domain name. It is ideal for managing web traffic with rules for routing, SSL termination, and load balancing.

For example, if you have several web apps running in your cluster, Ingress lets you serve them all under one domain with different paths, like example.com/app1 and example.com/app2. It simplifies your network setup and reduces the need for multiple load balancers or IP addresses.

Key Points

  • Ingress manages external HTTP/HTTPS access to services inside Kubernetes.
  • It uses rules based on hostnames and URL paths to route traffic.
  • An Ingress Controller is required to implement these rules.
  • Ingress simplifies exposing multiple services under one IP or domain.
  • Supports SSL termination and load balancing features.

Key Takeaways

Ingress routes external HTTP/HTTPS traffic to Kubernetes services using rules.
It requires an Ingress Controller to work inside the cluster.
Ingress lets you expose multiple services under one domain or IP.
Use Ingress to simplify traffic management and enable SSL termination.
It is essential for managing web access in production Kubernetes setups.