我正在 K8s 之外运行 consul 服务器。我有单独的 k8s 集群,所有节点均可访问。我目前没有运行任何 ACL 或 TLS。我收到以下错误,并且 K8s 中的注入器容器失败。
Consul 服务器值:
data_dir = "/opt/consul"
client_addr = "0.0.0.0"
ui_config{
enabled = true
}
server = true
advertise_addr = "192.168.60.10"
bootstrap_expect=1
错误:
2024-08-31T12:33:30.189Z [INFO] consul-server-connection-manager.consul-server-connection-manager: trying to connect to a Consul server
2024-08-31T12:33:30.296Z [ERROR] consul-server-connection-manager.consul-server-connection-manager: connection error: error="failed to discover Consul server addresses: failed to resolve DNS name: consul-consul-server.consul.svc: lookup consul-consul-server.consul.svc on 10.96.0.10:53: no such host"
即使我提供 externalServer 主机 IP 似乎也不起作用。我在这里错过了什么吗?
我对 k8s 的 helm 值
global:
enabled: false
tls:
enabled: false
externalServers:
enabled: true
hosts: ["192.168.60.10"]
server:
enabled: false
我使用helm安装了consul
helm install consul hashicorp/consul --namespace consul -f helm-values.yaml
K8s中的资源
NAME READY STATUS RESTARTS AGE
pod/consul-consul-connect-injector-bf57cf9b4-tzxcg 0/1 Running 0 30s
pod/consul-consul-gateway-resources-q44f7 0/1 Completed 0 2m42s
pod/consul-consul-webhook-cert-manager-7c656f9967-hsr8v 1/1 Running 0 30s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/consul-consul-connect-injector ClusterIP <none> 443/TCP 30s
service/consul-consul-dns ClusterIP <none> 53/TCP,53/UDP 30s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/consul-consul-connect-injector 0/1 1 0 30s
deployment.apps/consul-consul-webhook-cert-manager 1/1 1 1 30s
NAME DESIRED CURRENT READY AGE
replicaset.apps/consul-consul-connect-injector-bf57cf9b4 1 1 0 30s
replicaset.apps/consul-consul-webhook-cert-manager-7c656f9967 1 1 1 30s10.103.254.16610.97.215.246
当我检查注入容器中的日志时,它显示如下
k 日志-n consul pod/consul-consul-connect-injector-bf57cf9b4-tzxcg
2024-08-31T12:33:30.189Z [INFO] consul-server-connection-manager.consul-server-connection-manager: trying to connect to a Consul server
2024-08-31T12:33:30.296Z [ERROR] consul-server-connection-manager.consul-server-connection-manager: connection error: error="failed to discover Consul server addresses: failed to resolve DNS name: consul-consul-server.consul.svc: lookup consul-consul-server.consul.svc on 10.96.0.10:53: no such host"
我可以从 K8s pod ping 到 consul 服务器虚拟机 IP,也可以访问服务
curl http://192.168.60.10:8500/v1/catalog/services
{"consul":[]}
如果有人能告诉我这个设置有什么问题,我真诚地感激。
谢谢!
PS:我还检查了部署 consul-consul-connect-injector,它具有以下 ENV 变量
Environment:
NAMESPACE: (v1:metadata.namespace)
POD_NAME: (v1:metadata.name)
CONSUL_ADDRESSES: consul-consul-server.consul.svc
CONSUL_GRPC_PORT: 8502
CONSUL_HTTP_PORT: 8500
CONSUL_DATACENTER: dc1
CONSUL_API_TIMEOUT: 5s
您应该删除
helm-values.yaml
的缩进。应该是:
global:
enabled: false
tls:
enabled: false
externalServers:
enabled: true
hosts: ["192.168.60.10"]
server:
enabled: false