I have an ingress deployed in a k8s cluster in VMware. The issue is that the DNS responds inside the container:
[root@k8s-cluster ~]# kubectl exec -it -n test ingress-nginx-controller-848bfcb64d-n796z -- curl localhost/banana -H 'Host: k8s-cluster.lab.buch.int'
banana
But if I try from the cluster:
[root@k8s-cluster ~]# curl localhost/banana
curl: (7) Failed connect to localhost:80; Connection refused
It doesn't work even if I use the DNS instead of localhost or the IP assigned by metallb to the ingress controller.
[root@k8s-cluster ~]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
apple-service ClusterIP 10.97.109.66 <none> 5678/TCP 6d15h
banana-service ClusterIP 10.110.129.29 <none> 5678/TCP 6d15h
ingress-nginx-controller LoadBalancer 10.99.151.233 10.133.2.21 80:31981/TCP,443:30293/TCP 6d15h
ingress-nginx-controller-admission ClusterIP 10.108.116.127 <none> 443/TCP 6d15h
[root@k8s-cluster ~]# kubectl describe ing
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name: example-ingress
Namespace: test
Address: 10.133.65.148
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
k8s-cluster.lab.buch.int
/apple(/|$)(.*) apple-service:5678 (192.168.86.184:5678)
/banana(/|$)(.*) banana-service:5678 (192.168.76.157:5678)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
Events: <none>
If I curl the external ip assigned by metallb: 10.133.2.21
[root@k8s-cluster ~]# curl 10.133.2.21
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
So, it means that the nginx works in a some way, but if I try to curl 10.133.2.21/banana or 10.133.2.21/apple it doesn't work.
Any ideas?