无法在elasticsearch和curator之间建立连接

问题描述 投票:0回答:1

我的 Elastic Search 和 curator 都部署在同一个 Kubernetes 集群和同一个命名空间中。我已经在 curator 配置文件中的用户名和密码中给出了弹性主机名、端口和 http 身份验证,用于连接到弹性搜索。 但是当我运行 curator 作业时,我可以看到它默认为本地主机。所以我尝试使用集群 DNS 连接仍然是一样的

注意:我的弹性搜索公开为 NodePort。因此相应地给出主机名。

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/elastic_transport/_transport.py", line 342, in perform_request
  File "/usr/local/lib/python3.11/site-packages/elastic_transport/_node/_http_urllib3.py", line 202, in perform_request
elastic_transport.ConnectionError: Connection error caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f5c78b74cd0>: Failed to establish a new connection: [Errno 111] Connection refused)
2024-04-21 09:05:18,198 INFO      GET http://127.0.0.1:9200/ [status:N/A duration:0.000s]
2024-04-21 09:05:18,198 WARNING   Node <Urllib3HttpNode(http://127.0.0.1:9200)> has failed for 4 times in a row, putting on 8 second timeout
2024-04-21 09:05:18,198 CRITICAL  Unable to establish client connection to Elasticsearch!
2024-04-21 09:05:18,198 CRITICAL  Exception encountered: Connection error caused by: ConnectionError(Connection error caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f5c79554390>: Failed to establish a new connection: [Errno 111] Connection refuse

client:
      hosts: 
        - <my_cluster_master_hostname>
      port: <nodeport>
      url_prefix:
      use_ssl: False
      certificate:
      client_cert:
      client_key:
      ssl_no_validate: False
      http_auth: "username:password"
      timeout: 30
      master_only: False

注:

Elastic search version: 7.17.9
Curator version: curator:8.0.14

我想从管理者成功连接到部署在集群内的弹性搜索并管理索引,但每次它都默认为本地主机并且弹性没有部署在那里。因此无法管理弹性索引。

  1. 我尝试在 curator 配置文件中显式配置主机和端口以及凭据。
  2. 我还尝试使用 Kubernetes DNS 服务发现进行连接。

所有方法均无效。

注意:我可以使用相同的 URL 和身份验证使用弹性视图连接到我的弹性搜索,并在浏览器中点击它并按预期获得响应

elasticsearch kubernetes elasticsearch-curator elasticsearch-indices
1个回答
0
投票

不确定您的配置是否正确,但如果您尝试在同一集群内进行内部连接,我建议根据同一集群内的 DNS 解析配置主机名。

因此,如果 elasticsearch 所在的命名空间称为“es”,并且暴露 elasticsearch 的 K8s 服务称为“elastic”,则集群的 DNS 名称将为:

elastic.es.svc.cluster.local
。您的配置将如下所示:

hosts: 
  - elastic.es.svc.cluster.local
port: 9200

请注意,这是集群内 coredns 的默认配置。

© www.soinside.com 2019 - 2024. All rights reserved.