Junior — Middle
Can you explain what Kubernetes Ingress is and how it works for routing external traffic?
sobes.tech AI
Answer from AI
Kubernetes Ingress is an object in Kubernetes that manages external access to services within a cluster, usually via HTTP/HTTPS. Ingress allows defining routing rules that direct incoming traffic to the appropriate services based on URL, host, or other parameters.
Ingress works together with the Ingress Controller — a component that implements these rules and handles the traffic. For example, you can configure Ingress so that requests to example.com/api go to one service, and requests to example.com/web go to another.
An example of a simple Ingress manifest:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /web
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
Thus, Ingress simplifies external access management and allows flexible traffic routing within the cluster.