Minikube
Kubernetes
Ingress
Troubleshooting
DevOps

Minikube with ingress example not working

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When a Minikube ingress example does not work, the problem is usually not the YAML itself. Most failures come from missing cluster components, incorrect host resolution, or testing the wrong address.

Verify the Ingress Controller First

An Ingress resource is only a set of rules. It does nothing until an ingress controller watches those rules and configures a reverse proxy.

In Minikube, the usual first step is enabling the ingress addon.

bash
minikube start
minikube addons enable ingress
kubectl get pods -n ingress-nginx

Wait until the controller pod is running. If the pod is still pending or crashing, the Ingress resource will never route traffic correctly.

A quick health check is:

bash
kubectl get pods -n ingress-nginx
kubectl get svc -n ingress-nginx
kubectl get ingress

If kubectl get ingress shows your resource but the controller namespace is empty, the resource exists and the controller does not.

Use a Minimal Working Example

Before debugging a large application, reduce the problem to one deployment, one service, and one ingress rule.

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4  name: hello-web
5spec:
6  replicas: 1
7  selector:
8    matchLabels:
9      app: hello-web
10  template:
11    metadata:
12      labels:
13        app: hello-web
14    spec:
15      containers:
16        - name: hello-web
17          image: hashicorp/http-echo:1.0.0
18          args:
19            - "-text=hello from minikube"
20          ports:
21            - containerPort: 5678
22---
23apiVersion: v1
24kind: Service
25metadata:
26  name: hello-web
27spec:
28  selector:
29    app: hello-web
30  ports:
31    - port: 80
32      targetPort: 5678
33---
34apiVersion: networking.k8s.io/v1
35kind: Ingress
36metadata:
37  name: hello-web
38spec:
39  ingressClassName: nginx
40  rules:
41    - host: hello.local
42      http:
43        paths:
44          - path: /
45            pathType: Prefix
46            backend:
47              service:
48                name: hello-web
49                port:
50                  number: 80

Apply it with:

bash
kubectl apply -f hello-web.yaml
kubectl get all
kubectl get ingress hello-web

Make the Hostname Resolve Correctly

A valid Ingress rule still fails if your machine cannot resolve the host name to the Minikube node. This is the step many examples skip.

Find the cluster IP:

bash
minikube ip

Then map the host name to that IP in /etc/hosts.

text
192.168.49.2 hello.local

Use the actual IP returned by your cluster. After that, test with:

bash
curl http://hello.local/

If name resolution is the issue, curl to the raw IP may work while the hostname fails.

Check the Three Routing Layers

Ingress troubleshooting is easier if you inspect the request path as three separate hops:

  • Ingress routes to a Service
  • Service routes to Pod endpoints
  • Pod listens on the expected port

Useful commands:

bash
1kubectl describe ingress hello-web
2kubectl get svc hello-web -o wide
3kubectl get endpoints hello-web
4kubectl logs -n ingress-nginx deploy/ingress-nginx-controller

If the service has no endpoints, the selector does not match the pod labels. If endpoints exist but requests fail, confirm the container is listening on the target port.

Common Configuration Errors

One common issue is omitting ingressClassName: nginx. On modern clusters, that can leave the resource unclaimed by the controller.

Another frequent problem is expecting localhost to work. In Minikube, ingress traffic usually lands on the Minikube VM or container network, not on the host loopback interface.

Path configuration also causes failures. pathType is required in current Kubernetes APIs, and the backend service name and port must match the actual service object.

On some platforms, you may also need to be patient for a minute after enabling the addon. The controller deployment and admission components need time to become ready.

Common Pitfalls

The most common mistake is debugging the Ingress YAML before verifying the controller is installed and healthy.

Another mistake is testing the wrong hostname. If your rule says hello.local but you browse to the IP directly, host-based routing may not match.

A third mistake is confusing LoadBalancer behavior with Ingress behavior. In Minikube, minikube tunnel helps with LoadBalancer services, but ingress examples usually depend on the ingress controller and hostname routing instead.

Finally, do not assume the sample application is healthy. Always test the service first with kubectl port-forward or kubectl get endpoints before blaming ingress.

Summary

  • An Ingress resource needs a running ingress controller to do anything.
  • In Minikube, start by enabling the ingress addon.
  • Test with one minimal deployment, one service, and one ingress rule.
  • Map the ingress hostname to minikube ip so requests reach the cluster.
  • Verify service selectors, endpoints, and target ports before changing the Ingress YAML.
  • Most failures come from environment setup, not from the routing rule itself.

Course illustration
Course illustration

All Rights Reserved.