2017-06-19 24 views
0

我设置了一个入口控制器,一个具有节点端口的服务,设置健康路由并验证我的服务正在运行,但我的请求仍然被路由到我的默认后端,而不是到我的入口控制器。我不知道为什么,也不知道如何调试。Ingress Controller中的主机获取路由为默认后端

我已经检查:

  1. 我的豆荚是健康的(并且有一个健康的路线)
  2. 我有一个节点端口
  3. 有在describe没有错误的服务
  4. 我的服务从另一个荚

当我卷曲我的URL的作品,我得到这个:

$ curl image-pin.thejsj.com -v 
* Rebuilt URL to: image-pin.thejsj.com/ 
* Trying 35.186.225.114... 
* Connected to image-pin.thejsj.com (35.186.225.114) port 80 (#0) 
> GET/HTTP/1.1 
> Host: image-pin.thejsj.com 
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) 
> Accept: */* 
> Referer: 
> 
< HTTP/1.1 404 Not Found 
< Date: Mon, 19 Jun 2017 05:06:09 GMT 
< Content-Length: 21 
< Content-Type: text/plain; charset=utf-8 
< Via: 1.1 google 
< 
* Connection #0 to host image-pin.thejsj.com left intact 
default backend - 404 

我的资源声明:

入口控制器:

apiVersion: extensions/v1beta1 
kind: Ingress 
metadata: 
    name: "main-ingress" 
    labels: 
    # Timestamp used in order to force reload of the secret 
    last_updated: "1497848257" 
spec: 
    rules: 
    - host: image-pin.thejsj.com 
    http: 
     paths: 
     - path: /* 
     backend: 
      serviceName: imagepin 
      servicePort: 80 

服务

apiVersion: v1 
kind: Service 
metadata: 
    name: imagepin 
spec: 
    selector: 
    app: imagepin 
    type: NodePort 
    ports: 
    - protocol: "TCP" 
    port: 80 
    nodePort: 32222 
    targetPort: 80 

部署

apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: imagepin 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: imagepin 
    spec: 
     containers: 
     - name: imagepin 
      image: quay.io/hiphipjorge/imagepin_server:latest 
      args: 
      - "npm" 
      - "start" 
      ports: 
      - containerPort: 80 
      env: ... 
      readinessProbe: 
      httpGet: 
       path:/
       port: 80 
      livenessProbe: 
      httpGet: 
       path:/
       port: 80 

现状:

入口控制器:

Every 2.0s: kubectl describe ingress main-ingress        Jorges-MacBook-Pro-2.local: Sun Jun 18 22:01:35 2017 

Name:     main-ingress 
Namespace:    default 
Address:    35.186.225.114 
Default backend:  default-http-backend:80 (10.0.0.6:8080) 
Rules: 
    Host     Path Backends 
    ----     ---- -------- 
    image-pin.thejsj.com 
         /*  imagepin:80 (<none>) 
Annotations: 
    forwarding-rule:  k8s-fw-default-main-ingress--02988768680308cd 
    target-proxy:   k8s-tp-default-main-ingress--02988768680308cd 
    url-map:    k8s-um-default-main-ingress--02988768680308cd 
    backends:    {"k8s-be-31582--02988768680308cd":"HEALTHY","k8s-be-32222--02988768680308cd":"HEALTHY"} 
Events: 
    FirstSeen  LastSeen  Count From     SubObjectPath Type   Reason Message 
    ---------  --------  ----- ----     ------------- --------  ------ ------- 
    3m   3m    1  loadbalancer-controller     Normal   CREATE ip: 35.186.225.114 
    3m   3m    2  loadbalancer-controller     Normal   Service no user specified default bac 
kend, using system default 

服务

$ kubectl describe service imagepin 
Name:   imagepin 
Namespace:  default 
Labels:   <none> 
Annotations:  kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"imagepin","namespace":"default"},"spec":{"ports":[{"nodePort":32222,"port":80,... 
Selector:  app=imagepin 
Type:   NodePort 
IP:   10.3.241.98 
Port:   <unset> 80/TCP 
NodePort:  <unset> 32222/TCP 
Endpoints:  10.0.2.6:80 
Session Affinity: None 
Events:   <none> 
+0

通过转到GCP UI并删除所有未使用的后端来解决此问题。不知道这是如何相关,但... –

回答

0

尝试发送您的卷曲请求作为FOL低点:

卷曲进入-IP/-H “主持人:image-pin.thejsj.com

这可能会为你工作。

+0

这应该没有任何区别。这只是执行相同操作的不同方式。 – Rod