kubernetes – “externalTrafficPolicy”设置为“Local”时无响应

设置externalTrafficPolicy:Local时,无法访问以下Kubernetes服务.我通过NodePort直接访问它,但总是会超时.

{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "echo",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/echo",
    "uid": "c1b66aca-cc53-11e8-9062-d43d7ee2fdff",
    "resourceVersion": "5190074",
    "creationTimestamp": "2018-10-10T06:14:33Z",
    "labels": {
      "k8s-app": "echo"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "tcp-8080-8080-74xhz",
        "protocol": "TCP",
        "port": 8080,
        "targetPort": 3333,
        "nodePort": 30275
      }
    ],
    "selector": {
      "k8s-app": "echo"
    },
    "clusterIP": "10.101.223.0",
    "type": "NodePort",
    "sessionAffinity": "None",
    "externalTrafficPolicy": "Local"
  },
  "status": {
    "loadBalancer": {}
  }
}

我知道这个服务的pod需要在节点上可用,因为流量不会路由到其他节点.我查了一下.

最佳答案 不确定要连接的位置和键入的用于测试连接的命令或者您的环境是什么样的.但这很可能是由于
this known issue,如果kube-proxy无法找到运行它的节点的IP地址,则localTrafficPolicy设置为Local,无法访问节点端口.

这个link更加清楚地解决了这个问题.显然,kube-proxy上的–hostname-override在K8s 1.10中不起作用.您必须在kube-proxy ConfigMap中指定HostnameOverride选项.还有一个修复描述here,它将在未来的某个时候通过这篇文章使它上游.

点赞