Ingress Controller中的主机获取默认后端的路由

时间:2017-06-19 05:09:39

标签: kubernetes google-compute-engine

我设置了入口控制器,带有节点端口的服务,设置运行状况路由,并验证我的服务正在运行,但我的请求仍然被路由到我的默认后端而不是我的入口控制器。我不知道为什么,也不知道如何调试它。

我检查过:

  1. 我的豆荚健康(并且有健康路径)
  2. 我有一个节点端口
  3. 服务的describe
  4. 没有错误
  5. 我的服务适用于其他广告
  6. 当我卷曲我的网址时,我明白了:

    $ 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
    

    我的资源声明:

    Ingress Controller:

    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
    

    当前状态:

    Ingress Controller:

    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>
    

1 个答案:

答案 0 :(得分:0)

尝试发送您的卷曲请求,如下所示:

卷曲 ingress-ip / -H“主持人: image-pin.thejsj.com

这可能适合你。