我在 VMware 的 k8s 集群中部署了一个入口。问题是 DNS 在容器内响应:
[root@k8s-cluster ~]# kubectl exec -it -n test ingress-nginx-controller-848bfcb64d-n796z -- curl localhost/banana -H 'Host: k8s-cluster.lab.buch.int'
banana
但是,如果我从集群中尝试:
[root@k8s-cluster ~]# curl localhost/banana
curl: (7) Failed connect to localhost:80; Connection refused
即使我使用 DNS 而不是 localhost 或 metallb 分配给入口控制器的 IP,它也不起作用。
[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>
如果我 curl 由 metallb 分配的外部 ip: 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>
所以,这意味着 nginx 以某种方式工作,但如果我尝试 curl 10.133.2.21/banana 或 10.133.2.21/apple 它不起作用。
有任何想法吗?