DEV Community

Said Olano
Said Olano

Posted on

⚙️ What is an Ingress Controller?

An Ingress is a configuration resource in Kubernetes that defines how external requests are routed to internal services.
For example, with an Ingress you can define rules like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - host: app.mydomain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 8080
Enter fullscreen mode Exit fullscreen mode

💡 Practical example

Let’s say you have two services in your cluster:

frontend (port 80)

backend (port 8080)

You could define a single Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
spec:
  rules:
  - host: myapp.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: frontend
            port:
              number: 80
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: backend
            port:
              number: 8080
Enter fullscreen mode Exit fullscreen mode

👉 This allows:

myapp.com/ → routes to the frontend
myapp.com/api → routes to the backend

Top comments (0)