gCloud容器(GKE)Kubernetes服务端口8000无法访问

时间:2015-11-23 01:04:46

标签: kubernetes google-kubernetes-engine

当我尝试访问公共IP的http曝光时,我收到此错误。

RajRajen:lb4btest rajrajen$ curl http://104.154.84.143:8000
curl: (56) Recv failure: Connection reset by peer

RajRajen:lb4btest rajrajen$ telnet 104.154.84.143 8000
Trying 104.154.84.143...
Connected to 143.84.154.104.bc.googleusercontent.com.
Escape character is '^]'.
Connection closed by foreign host.
RajRajen:lb4btest rajrajen$

<请注意上面的IP只是表示,一旦我重新部署,IP可能会改变。但问题不在于>

我的json文件中的控制器URL。

RajRajen:lb4btest rajrajen$ kubectl create -f middleware-service.json 
services/lb4b-api-v9

和rc - 复制控制器json文件。

{
"kind": "ReplicationController",
"apiVersion": "v1",
"metadata": {
  "name": "lb4b-api-v9",
  "labels": {
    "app": "lb4bapi",
    "tier": "middleware"
}
},
"spec": {
"replicas": 1,
"selector": {
  "app": "lb4bapi",
  "tier": "middleware"
},
"template": {
  "metadata": {
    "labels": {
      "app": "lb4bapi",
      "tier": "middleware"
    }
  },
  "spec": {
    "containers": [
      {
        "name": "lb4bapicontainer",
        "image": "gcr.io/helloworldnodejs-1119/myproject",
        "resources": {
          "requests": {
            "cpu": "500m",
            "memory": "128Mi"
          }
        },
        "env": [
          {
            "name": "GET_HOSTS_FROM",
            "value": "dns"
          },
          {
            "name": "PORT",
            "value": "8000"
          }
        ],
        "ports": [
          {
            "name": "middleware",
            "containerPort": 8000,
            "hostPort": 8000
          }
        ]
      }
    ]
  }
}
}
}

这是服务json文件

{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
  "name": "lb4b-api-v9",
  "labels": {
      "name": "lb4b-api-v9",
      "app": "lb4bmiddleware",
      "tier": "middleware"
  }    
},    
"spec": {
    "type": "LoadBalancer",
    "selector": {
        "name": "lb4b-api-v9",            
        "app": "lb4bmiddleware",
        "tier": "middleware"
    },
    "ports": [
        {
            "protocol": "TCP",
            "port": 8000
        }
    ]
  }
}    

根据pm2要求,Docker容器正在以非root 用户身份运行节点应用程序。

 ENTRYPOINT ["pm2"]
 CMD ["start", "app.js", "--no-daemon"]

我完全能够在POD泊坞窗内以及NODE内部对此POD本地IP卷曲http://podIP:podPort进行卷曲。    但无法在NODE内的http://serviceLocalIP:8000进行卷曲。

你能提出一些建议吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

此问题已解决。在执行有关服务端点的故障排除注释后,尤其是保持SERVICE选择器值与POD选择器值相同。

https://cloud.google.com/container-engine/docs/debugging/

搜索我的服务缺少端点

Controller.json中的解决方案

     {
 "kind": "ReplicationController",
  "apiVersion": "v1",
  "metadata": {
   "name": "lb4b-api-v9",
   "labels": {
         "name": "lb4b-api-v9",            
        "app": "lb4bmiddleware",
        "tier": "middleware"
  }
},
"spec": {
"replicas": 1,
"selector": {
        **"name": "lb4b-api-v9",            
        "app": "lb4bmiddleware",
        "tier": "middleware"**
},
"template": {
  "metadata": {
    "labels": {
        "name": "lb4b-api-v9",            
        "app": "lb4bmiddleware",
        "tier": "middleware"
     }
        },
        "spec": {
      "containers": [
      {
        "name": "lb4b-api-v9",
        "image": "gcr.io/myprojectid/myproect",
        "resources": {
          "requests": {
            "cpu": "500m",
            "memory": "128Mi"
          }
        },
        "env": [
          {
            "name": "GET_HOSTS_FROM",
            "value": "dns"
          },
          {
            "name": "PORT",
            "value": "8000"
          }
        ],
        "ports": [
          {
            "name": "middleware",
            "containerPort": 8000,
            "hostPort": 8000
          }
        ]
      }
    ]
  }
}
}
}

在Service.json中

 {
"kind": "Service",
"apiVersion": "v1",
"metadata": {
  "name": "lb4b-api-v9",
  "labels": {
      "name": "lb4b-api-v9",
      "app": "lb4bmiddleware",
      "tier": "middleware"
  }    
},    
"spec": {
    "type": "LoadBalancer",
    "selector": {
        **"name": "lb4b-api-v9",            
        "app": "lb4bmiddleware",
        "tier": "middleware"**
    },
    "ports": [
        {
            "protocol": "TCP",
            "port": 8000
        }
    ]
}
 }    

多数人..