Kubernetes 无法从机器内部卷曲入口:404

Kubernetes 无法从机器内部卷曲入口:404,kubernetes,nginx-ingress,Kubernetes,Nginx Ingress,集群运行在Ubuntu 18.06机器(VPS)上。它在前面使用金属负载平衡器。 那么,到目前为止我尝试了什么: curl 192.168.0.12:8080/system/ipaddr工作正常!(卷起豆荚) curl 10.97.125.155:31001/system/ipaddr工作正常!(服务) curl 192.168.1.240/articleservice/system/ipaddr失败->404 入口nginx的日志: 下面是pod、服务和入口的描述输出。 kubect

集群运行在Ubuntu 18.06机器(VPS)上。它在前面使用金属负载平衡器。

那么,到目前为止我尝试了什么:

  • curl 192.168.0.12:8080/system/ipaddr
    工作正常!(卷起豆荚)
  • curl 10.97.125.155:31001/system/ipaddr
    工作正常!(服务)
  • curl 192.168.1.240/articleservice/system/ipaddr
    失败->404
入口nginx的日志

下面是pod、服务和入口的描述输出。




kubectl服务的输出

kubectl描述入口文章服务入口的输出

名称:articleservice入口
名称空间:默认值
地址:192.168.1.240
默认后端:默认http后端:80()
规则:
主机路径后端
----        ----  --------
elpsit.com
/articleservice articleservice:31001()
注释:
nginx.ingres.kubernetes.io/rewrite-target:/
活动:
从消息中键入原因年龄
----    ------  ----  ----                      -------
正常创建2500万nginx入口控制器入口默认/articleservice入口
正常更新25m nginx入口控制器入口默认/articleservice入口

正如@Matthew L Daniel已经提到的:我需要像这样定义入口主机:


curl-vH'主机:elpsit.com'http://192.168.1.240/articleservice/system/ipaddr

您的入口前面有服务吗?我的入口前面有一个
入口控制器。谢谢你的提示,我看了一下日志,发现服务有些奇怪。随附上述日志:)因为,入口控制器是基于虚拟主机的,这意味着您不能在没有与您在
ingres
资源中看到的
host
值相匹配的
host:
头的情况下为其提供IP,否则它不知道应该将它们路由到哪个
服务
后端
。抱歉,显然,我仍然没有真正理解这一点,并认为这是另一个问题。这就解决了,谢谢。
I1229 20:05:59.688397       9 event.go:221] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"articleservice-ingress", UID:"28fef789-0ba5-11e9-a12a-0050563e015b", APIVersion:"extensions/v1beta1", ResourceVersion:"630309", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress default/articleservice-ingress
W1229 20:05:59.688797       9 controller.go:826] Service "default/articleservice" does not have any active Endpoint.
173.249.46.84 - [173.249.46.84] - - [29/Dec/2018:20:22:07 +0000] "GET /articleservice/getAllArticles HTTP/1.1" 404 153 "-" "curl/7.61.0" 354 0.000 [-] - - - - 0dad96ea6a6be639cd62544c7871a52e
  Name:               articleservice-deployment-5d78cc95f-jfctl
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               server.net/173.249.46.84
    Start Time:         Sat, 29 Dec 2018 21:06:05 +0100
    Labels:             app=articleservice
                        pod-template-hash=5d78cc95f
    Annotations:        cni.projectcalico.org/podIP: 192.168.0.12/32
    Status:             Running
    IP:                 192.168.0.12
    Controlled By:      ReplicaSet/articleservice-deployment-5d78cc95f
    Containers:
      articleservice:
        Container ID:   docker://04d9fd926966fd5a45829776a0d5d85198a6920e0f98d8d8b3cb4802897f66f0
        Image:          elps/articleservice:1.0.8
        Image ID:       docker-pullable://elps/articleservice@sha256:813c36c53d2b5199baa7223d4f348c5ab181cb8b233d4b47be801079cad6b743
        Ports:          8080/TCP, 5005/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Sat, 29 Dec 2018 21:06:18 +0100
        Ready:          True
        Restart Count:  0
        Environment:
          ARTICLE_SERVICE_HOST:   <set to the key 'articleservice-host' of config map 'articleservice-configmap'>   Optional: false
          ARTICLE_SERVICE_PORT:   <set to the key 'articleservice-port' of config map 'articleservice-configmap'>   Optional: false
          ARTICLE_SERVICE_PATH:   <set to the key 'articleservice-path' of config map 'articleservice-configmap'>   Optional: false
          CART_SERVICE_HOST:      <set to the key 'cartservice-host' of config map 'articleservice-configmap'>      Optional: false
          CART_SERVICE_PORT:      <set to the key 'cartservice-port' of config map 'articleservice-configmap'>      Optional: false
          CART_SERVICE_PATH:      <set to the key 'cartservice-path' of config map 'articleservice-configmap'>      Optional: false
          CATALOG_SERVICE_HOST:   <set to the key 'catalogservice-host' of config map 'articleservice-configmap'>   Optional: false
          CATALOG_SERVICE_PORT:   <set to the key 'catalogservice-port' of config map 'articleservice-configmap'>   Optional: false
          CATALOG_SERVICE_PATH:   <set to the key 'catalogservice-path' of config map 'articleservice-configmap'>   Optional: false
          CUSTOMER_SERVICE_HOST:  <set to the key 'customerservice-host' of config map 'articleservice-configmap'>  Optional: false
          CUSTOMER_SERVICE_PORT:  <set to the key 'customerservice-port' of config map 'articleservice-configmap'>  Optional: false
          CUSTOMER_SERVICE_PATH:  <set to the key 'customerservice-path' of config map 'articleservice-configmap'>  Optional: false
          MYSQL_HOST:             <set to the key 'database-host' of config map 'articleservice-configmap'>         Optional: false
          MYSQL_DB:               <set to the key 'database-name' of config map 'articleservice-configmap'>         Optional: false
          MYSQL_USER:             <set to the key 'database-user' in secret 'articleservice-secret'>                Optional: false
          MYSQL_PASSWORD:         <set to the key 'database-password' in secret 'articleservice-secret'>            Optional: false
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-zp5k9 (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             True 
      ContainersReady   True 
      PodScheduled      True 
    Volumes:
      default-token-zp5k9:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-zp5k9
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
Name:                     articleservice
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=articleservice
Type:                     NodePort
IP:                       10.97.125.155
Port:                     web  31001/TCP
TargetPort:               8080/TCP
NodePort:                 web  31001/TCP
Endpoints:                192.168.0.12:8080
Port:                     debug  5005/TCP
TargetPort:               5005/TCP
NodePort:                 debug  32001/TCP
Endpoints:                192.168.0.12:5005
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
Name:             articleservice-ingress
Namespace:        default
Address:          192.168.1.240
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  elpsit.com  
              /articleservice   articleservice:31001 (<none>)
Annotations:
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  25m   nginx-ingress-controller  Ingress default/articleservice-ingress
  Normal  UPDATE  25m   nginx-ingress-controller  Ingress default/articleservice-ingress