Fluentd 无法连接到 ElasticSearch 集群

Fluentd Failing to connect to ElasticSearch cluster

我有一个本地 kubernetes 集群,我在其中使用预配置的 elasticsearch 映像 (fluent/fluentd-kubernetes-daemonset:elasticsearch) 添加了一个 Fluentd Daemonset。 this article 的第 2 步。我在云中也有一个弹性集群 运行。您可以将一些环境变量传递给 fluentd-elasticsearch 图像进行配置。它看起来很简单,但是当 运行 fluentd Pod 时,我不断收到错误消息:

"Fluent::ElasticsearchOutput::ConnectionFailure" error="Can not reach Elasticsearch cluster ({:host=>\"fa0acce34bf64db9bc9e46f98743c185.westeurope.azure.elastic-cloud.com\", :port=>9243, :scheme=>\"https\", :user=>\"username\", :password=>\"obfuscated\"})!" plugin_id="out_es"

当我尝试从 pod 中访问弹性集群时 # wget https://fa0acce34bf64db9bc9e46f98743c185.westeurope.azure.elastic-cloud.com:9243/ 我得到一个 401 unauthorized(因为我没有在这里提交 user/pass),但它至少表明该地址是可达的。

为什么连接失败? 我已经将 FLUENT_ELASTICSEARCH_SSL_VERSION 设置为 'TLSv1_2',我看到这为其他人解决了一些问题。

Daemonset 配置:

kind: DaemonSet
metadata:
  name: fluentd
  namespace: kube-logging
  labels:
    app: fluentd
    k8s-app: fluentd-logging
    version: v1
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      app: fluentd
  template:
    metadata:
      labels:
        app: fluentd
        k8s-app: fluentd-logging
        version: v1
        kubernetes.io/cluster-service: "true"
    spec:
      serviceAccount: fluentd
      serviceAccountName: fluentd
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:elasticsearch
        env:
        - name:  FLUENT_ELASTICSEARCH_HOST
          value: "fa0acce34bf64db9bc9e46f98743c185.westeurope.azure.elastic-cloud.com"
        - name:  FLUENT_ELASTICSEARCH_PORT
          value: "9243"
        - name: FLUENT_ELASTICSEARCH_SCHEME
          value: "https"
        - name: FLUENT_UID
          value: "0"
        - name: FLUENT_ELASTICSEARCH_SSL_VERIFY
          value: "false"
        - name: FLUENT_ELASTICSEARCH_SSL_VERSION
          value: "TLSv1_2"
        - name: FLUENT_ELASTICSEARCH_USER
          value: "<user>"
        - name: FLUENT_ELASTICSEARCH_PASSWORD
          value: "<password>"
        resources:
          limits:
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers

对于遇到此问题的任何其他人:

我正在学习使用 'image: fluent/fluentd-kubernetes-daemonset:elasticsearch' 图片的教程。当您查看他们的 DockerHub (https://hub.docker.com/r/fluent/fluentd-kubernetes-daemonset) 时,您可以看到 :elaticsearch 标签已有一年历史并且可能已过时。

我将 DaemonSet 的图像更改为更新更稳定的标签 'fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch' 并且它现在可以正常工作了。