【问题标题】:How to configure Elasticsearch Index Lifecycle Management (ILM) in eck-operator如何在 eck-operator 中配置 Elasticsearch 索引生命周期管理 (ILM)
【发布时间】:2022-08-04 23:18:38
【问题描述】:

我使用来自官方弹性存储库的 eck-operator(带有 eck-operator-crd) https://artifacthub.io/packages/helm/elastic/eck-operator Kibana 和 Elasticsearch 清单正在部署并且工作正常。 我的问题是如何配置附加功能,例如: 索引生命周期策略、Kibana 数据视图、新模板、数据流、仪表板等? 我看到很少有运营商有清单,但上面没有提到。 感谢您的任何评论。

    标签: docker elasticsearch kubernetes cloud kibana


    【解决方案1】:

    我们通过配置映射来做到这一点。我们将索引模板和索引生命周期策略存储为 json 格式。此外,执行脚本是配置映射的一部分,它通过 POST 将索引模板和 ilm 策略推送到 elasticsearch。由于现在所有内容都在卷中,因此我们创建了一个 cron 作业来执行此脚本。

    例如这是索引模板 所有索引.json:

    {
        "index_patterns": ["abc*"],
        "priority": 300,
        "composed_of": ["template1", "template2"], 
        "version": 3
    }
    

    执行脚本.sh

     curl -XPUT "http://some_url:9200/_index_template/all-indices" -H 'Content-Type: application/json' -d @/etc/elasticsearch-templates/all-indices.json  
    

    我们从 terraform 创建这些配置图。

    kibana.yaml

    ...
      podTemplate:
        spec:
          containers:
          - name: kibana
            volumeMounts:
            - name: elasticsearch-templates
              mountPath: /etc/elasticsearch-templates
              readOnly: true
            lifecycle:
              postStart:
                exec:
                  command: ["/bin/sh", "-c", "sleep 15 && sh /etc/elasticsearch-templates/execution-script.sh"]
          volumes:
            - name: elasticsearch-templates
              configMap:
                name: ilm-and-index-templates
    

    然后cron作业执行脚本

    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: script-execution
    spec:
      schedule: "0 5 * * *"
      jobTemplate:
        spec:
          template:
            spec:
              containers:
              - name: script-execution
                image: alpine/curl:latest
                imagePullPolicy: IfNotPresent
                command:
                - /bin/sh
                - -c
                - sh /etc/elasticsearch-templates/execution-script.sh
                volumeMounts:
                - name: elasticsearch-templates
                  mountPath: /etc/elasticsearch-templates
                  readOnly: true
              restartPolicy: OnFailure
              volumes:
                - name: elasticsearch-templates
                  configMap:
                    name: ilm-and-index-templates
    

    【讨论】:

      猜你喜欢
      • 2023-01-13
      • 1970-01-01
      • 2020-12-01
      • 2020-05-08
      • 2020-12-07
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多