An Ingress is a Kubernetes resource that manages external HTTP/S access to services in your cluster β typically via hostnames, paths, and TLS.
β Without Ingress: Youβd need NodePort or LoadBalancer for every service.
π With Ingress: One entry point routes traffic to many services.
Like a reception desk in an office building:
- Visitor says: βIβm here for marketingβ β sent to floor 3
- Visitor says: βIβm here for engineeringβ β sent to floor 5
- The building has one front door (Ingress), but many internal offices (Services)
Assume you have:
web Service (app: web)api Service (app: api)Step 1: Create an Ingress Resource
# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
meta
name: main-ingress
namespace: default
spec:
rules:
- host: web.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80
- host: api.example.com
http:
paths:
- path: /v1
pathType: Prefix
backend:
service:
name: api
port:
number: 80
Apply it:
kubectl apply -f ingress.yaml
β Result:
http://web.example.com β web Servicehttp://api.example.com/v1 β api Serviceβ οΈ But wait! This wonβt work yet β you need an Ingress Controller (next topic).