尝试从K8S外部的客户端访问K8S中的Consul服务器的“请求的地址无效”

时间:2019-06-18 13:13:43

标签: kubernetes consul

我在Stratoscale的Symphony中有一个K8S集群(运行Linux)。它具有由Symphony分配的群集IP地址IP1。我已经在群集中安装了Consul。我可以将Consul KV密钥“放入”一个容器中(通过容器的网页上可用的命令行界面),然后从另一个容器中“获取”。就端口而言,称为“ consul-consul-server”的K8S Consul服务具有以下规范:

{
  "kind": "Service",
  "metadata": {
    "name": "consul-consul-server",
    "namespace": "consul",
    ...
  },
  "spec": {
    "ports": [
      {
        "name": "http",
        "protocol": "TCP",
        "port": 8500,
        "targetPort": 8500,
        "nodePort": 30323
      },
      {
        "name": "serflan-tcp",
        "protocol": "TCP",
        "port": 8301,
        "targetPort": 8301,
        "nodePort": 31056
      },
      {
        "name": "serflan-udp",
        "protocol": "UDP",
        "port": 8301,
        "targetPort": 8301,
        "nodePort": 31056
      },
      {
        "name": "serfwan-tcp",
        "protocol": "TCP",
        "port": 8302,
        "targetPort": 8302,
        "nodePort": 30717
      },
      {
        "name": "serfwan-udp",
        "protocol": "UDP",
        "port": 8302,
        "targetPort": 8302,
        "nodePort": 30717
      },
      {
        "name": "server",
        "protocol": "TCP",
        "port": 8300,
        "targetPort": 8300,
        "nodePort": 32091
      },
      {
        "name": "dns-tcp",
        "protocol": "TCP",
        "port": 8600,
        "targetPort": "dns-tcp",
        "nodePort": 31688
      },
      {
        "name": "dns-udp",
        "protocol": "UDP",
        "port": 8600,
        "targetPort": "dns-udp",
        "nodePort": 31688
      }
    ],
    "selector": {
      "app": "consul",
      "component": "server",
      "release": "consul"
    },
    "clusterIP": "10.104.86.253",
    "type": "NodePort",
    "externalTrafficPolicy": "Cluster",
  },
  "status": {
    "loadBalancer": {}
  }
}

如何从群集外部从命令行启动Consul客户端代理?根据我在https://www.consul.io/docs/agent/cloud-auto-join.html#kubernetes-k8s-中所读的内容,我尝试了以下操作:

领事代理-retry-join“ provider = k8s namespace = consul label_selector = \” app = consul,component = server \“ host_network = true” -client = -bind = -join = -config-file = C:\ Config \ consul.hcl -server-port = 32091

和其他一些组合,但它们均导致此错误:

==> Starting Consul agent...
==> Error starting agent: 2 errors occurred:
        * listen udp 161.92.250.34:8600: bind: The requested address is not valid in its context.
        * listen tcp 161.92.250.34:8600: bind: The requested address is not valid in its context.

知道我在做什么错吗?预先感谢。

1 个答案:

答案 0 :(得分:0)

事实证明,我应该以不同的方式称呼“领事代理-retry-join”:

领事代理--retry-join = :8500 -bind =

这对我有用。