kubernetes - “请求的地址无效”试图从 K8S 外部的客户端访问 K8S 中的 Consul 服务器
问题描述
我在 Stratoscale 的 Symphony 中有一个 K8S 集群(运行 Linux)。它有一个由 Symphony 分配的集群 IP 地址 IP1。我已经在集群中安装了 Consul。我能够将 Consul KV 密钥“放入”一个 pod(通过 pod 网页上提供的命令行界面)并从另一个 pod 中“获取”它。就端口而言,名为“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=<IP1> -bind=<LocalIP> -join=<IP1> -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.
知道我做错了什么吗?提前致谢。
解决方案
事实证明,我应该以不同的方式调用“consul agent -retry-join”:
领事代理 --retry-join=<IP1>:8500 -bind=<LocalIP>
这对我有用。
推荐阅读
- java - 将同名 xml 节点添加到 arrayList
- node.js - 提供数据处理的进展
- php - 无法再次获得 .htaccess 工作
- java - 如何使用我的正则表达式匹配多次出现?
- python - 我有一个清单,我需要在每一行打印出 10 个项目?
- c++ - OpenMP 任务等待不工作
- c# - 无法创建跨平台 ARCore 会话 (ErrorInvalidArgument)。GoogleARCoreInternal.ARCoreIOSLifecycleManager:EnableSession()
- javascript - 使用(引导)HTML 和纯 Javascript 创建待办事项列表
- c - 为什么 for 循环终止但其中的 memcpy 复制相同的子字符串?
- laravel - 在laravel中使用数组过滤集合