0
0
Kubernetesdevops~3 mins

Why Ingress resource definition in Kubernetes? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could control all your app traffic with just one simple rule set?

The Scenario

Imagine you have many websites or services running on different servers, and you want to let users access them all through one single address.

Without a smart way to manage this, you would have to tell users exactly which server and port to use for each service.

The Problem

Manually configuring each service's address and port is confusing and error-prone.

Users might get lost or connect to the wrong service.

Also, updating these settings every time you add or change a service takes a lot of time and can cause downtime.

The Solution

An Ingress resource in Kubernetes acts like a smart traffic controller.

It lets you define rules to route user requests to the right service based on the URL or host name.

This way, you only need one entry point, and Kubernetes handles the rest automatically.

Before vs After
Before
kubectl expose pod myapp --port=8080
kubectl expose pod myapi --port=9090
Users must use IP:8080 or IP:9090
After
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: myapp.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: myapp
            port:
              number: 80
What It Enables

It enables simple, centralized access to multiple services through friendly URLs, improving user experience and operational efficiency.

Real Life Example

A company runs a website, a blog, and an API service on Kubernetes.

Using Ingress, they let users visit www.company.com for the website, blog.company.com for the blog, and api.company.com for the API, all through one IP address.

Key Takeaways

Manual service access is confusing and hard to maintain.

Ingress defines rules to route traffic smartly inside Kubernetes.

This simplifies access and scales easily as services grow.