This guide explains how to configure Ingress in a Minikube-based Kubernetes cluster to enable clean routing for your microservices (e.g., users, products).
- Minikube installed and running.
- NGINX Ingress addon enabled.
- Microservices (e.g., users, products) deployed via Helm, using local Docker images.
- Services should be running and exposing HTTP ports (e.g., 8000).
This adds the NGINX ingress controller under the ingress-nginx namespace.
minikube addons enable ingressTo access services via a domain like app.local, add this line to your local /etc/hosts file:
127.0.0.1 app.localNote:
- On Linux/macOS: Use sudo nano /etc/hosts
- On Windows: Edit C:\Windows\System32\drivers\etc\hosts as administrator.
Create a file named ingress.yaml with the following content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- host: app.local
http:
paths:
- pathType: ImplementationSpecific
path: /users(/|$)(.*)
backend:
service:
name: users-service
port:
number: 8000
- pathType: ImplementationSpecific
path: /products(/|$)(.*)
backend:
service:
name: products-service
port:
number: 8000
- Ensure
service.nameexactly matches the name of the service deployed by Helm. You can confirm via:
kubectl get svc- Match the correct exposed port (e.g., 8000 if your app listens on that).
- Do not use regex-like paths such as
/users(/|$)(.*)withpathType: Prefix. Instead, usepathType: ImplementationSpecific.
Run
kubectl apply -f ingress.yaml
kubectl get ingressIf you see a 503 error later, verify that the service name and port are correct.
Now test the routing:
http://app.local/usershttp://app.local/products
curl -H "Host: app.local" http://$(minikube ip)/users/health
curl -H "Host: app.local" http://$(minikube ip)/products/healthTo remove the ingress resource:
kubectl delete ingress app-ingress| Issue | Cause | Fix |
|---|---|---|
| 503 Service Temporarily Unavailable | Ingress can't find the service | Ensure service.name and port.number are correct |
| Error obtaining Endpoints... | Wrong service.name in ingress.yaml |
Use kubectl get svc to find the actual service names |
DNS not resolving app.local |
Missing /etc/hosts entry |
Add 127.0.0.1 app.local to your hosts file |
| Path regex not accepted | Using `/path(/ | $)(.*)withpathType: Prefix` |