MacOS Big Sur 11.6.8
minikube version: v1.28.0
Following several tutorials on ingress and attempting to get it working locally. Everything appears to work: manual minikube service foo
works, kubectl get ingress
shows an IP, pinging the designated host name resolves the expected IP, etc. I went through a few different tutes with the same results.
I boiled it down to the simplest replication from the tutorial at kubernetes.io :
# kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
# kubectl expose deployment web --type=NodePort --port=8080
# kubectl get service web (ensure it's a node port)
# minikube service web --url (test url)
# kubectl apply -f ingress_hello_world.yaml
# curl localkube.com
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: localkube.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 8080
Manual service works:
>minikube service web --url
http://127.0.0.1:50111
❗ Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
>curl http://127.0.0.1:50111
Hello, world!
Version: 1.0.0
Hostname: web-84fb9498c7-hnphb
Ingress looks good:
>minikube addons list | grep ingress
| ingress | minikube | enabled ✅ | Kubernetes |
>kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress nginx localkube.com 192.168.49.2 80 15m
ping resolves the address mapped in /etc/hosts:
>ping localkube.com
PING localkube.com (192.168.49.2): 56 data bytes
I have looked through similar questions with no positive results. I have gone from this simple example to apache to mongo deployments via config files. Each time I can get to the app through a manual service mapping or by creating an external service (LoadBalancer / nodePort), but when I get to the Ingress part the config applies with no errors and everything appears to be working except for it actually… working.
2
Answers
Based on Veera's answer, I looked into the ingress issue with macOS and
minikube tunnel
. To save others the hassle, here is how I resolved the issue:minikube ssh
you can ping and curl the minikube IP and the domain name you mapped to that IP in /etc/hosts. However, this does not help trying to access the service from a browser.sudo minikube tunnel
will keep a base tunnel open, and create tunneling for any existing or new ingress components. This combined with the ingress rules will mimic host header style connecting to any domain resolving to the local host.Here is a full example of a working solution on mac. Dump this to a file named ingress_hello_world.yaml and follow the commented instructions to achieve a simple ingress solution that routes 2 domains to 2 different services (note this will work with pretty much any internal service, and can be a ClusterIP instead of NodePort):
The behavior you are describing is most probably because the
ingress and ingress-dns addons
are currently only supported on Linux Systems when using the Docker driver, as mentioned in the Known Issues section of the minikube documentation.Minikube supports ingress differently on the Mac and Linux.
On Linux the ingress is fully supported and therefore does not need the use of minikube tunnel.
On Mac there is an open issue due to a network issue. The documentation states that the minikube ingress addon is not supported, seems misleading if not incorrect. It’s just supported differently (and not as well).
Please go through Ingress DNS and similar SO for more information.