k8s ingres访问失败

学习环境
所使用的pod信息


kubectl get pod -n test -o wide
NAME                                 READY   STATUS    RESTARTS      AGE   IP               NODE        NOMINATED NODE   READINESS GATES
nginx-deployment-5c767764f5-5ffpm    1/1     Running   1 (17h ago)   17h   10.244.169.167   k8s-node2   <none>           <none>
nginx-deployment-5c767764f5-6gs8s    1/1     Running   1 (17h ago)   17h   10.244.169.166   k8s-node2   <none>           <none>
nginx-deployment-5c767764f5-vcnmv    1/1     Running   1 (17h ago)   17h   10.244.36.98     k8s-node1   <none>           <none>
tomcat-deployment-7db86c59b7-kmbls   1/1     Running   1 (17h ago)   17h   10.244.36.97     k8s-node1   <none>           <none>
tomcat-deployment-7db86c59b7-krh95   1/1     Running   1 (17h ago)   17h   10.244.169.165   k8s-node2   <none>           <none>
tomcat-deployment-7db86c59b7-zbp5g   1/1     Running   1 (17h ago)   17h   10.244.36.96     k8s-node1   <none>           <none>
#ingress pod 信息
kubectl get pod -n ingress-nginx
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create--1-cxqkl     0/1     Completed   0          7m9s
ingress-nginx-admission-patch--1-t6whc      0/1     Completed   0          7m9s
ingress-nginx-controller-6b64bc6f47-qqgf2   1/1     Running     0          7m9s
#ingress service创建信息
kubectl get svc -n ingress-nginx
NAME                                 TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.1.71.159   <none>        80:32704/TCP,443:32764/TCP   5m28s
ingress-nginx-controller-admission   ClusterIP   10.1.56.158   <none>        443/TCP                      5m28s

规则创建信息

kubectl get ing -n test
NAME           CLASS             HOSTS                            ADDRESS   PORTS   AGE
ingress-http   ingress-example   nginx.test.com,tomcat.test.com             80      17h
#详细信息 ingress
kubectl describe ing -n test
Name:             ingress-http
Namespace:        test
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host             Path  Backends
  ----             ----  --------
  nginx.test.com   
                   /   nginx-service:80 (10.244.169.166:80,10.244.169.167:80,10.244.36.98:80)
  tomcat.test.com  
                   /   tomcat-service:8080 (10.244.169.165:8080,10.244.36.96:8080,10.244.36.97:8080)
Annotations:       <none>
Events:            <none>
hosts 文件信息

192.168.100.60 nginx.test.com
192.168.100.60 tomcat.test.com 

访问失败


curl nginx.test.com:32704
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

我想要达到的结果 ,是以域名的方式访问到如下结果。
这边是直接访问的调度pod

curl 10.244.169.167
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>

看下你的ingress转发配置,
要确认转发规则有没有配置正确。

这个报错的意思呢,就是需要给ingress控制器配置一个default-http-backend的svc。
如果ingress对象中的主机或路径都不匹配http请求,就会把流量分给这个default-http-backend并返回一个404。
参考下面这篇文章
https://blog.csdn.net/fangfu123/article/details/121638163