Movatterモバイル変換


[0]ホーム

URL:


Loading
  1. Elastic Docs/
  2. Deploy and manage/
  3. Deploy/
  4. Elastic Cloud on Kubernetes/
  5. Manage deployments/
  6. Configure deployments/
  7. Elasticsearch configuration

Custom configuration files and plugins

To run Elasticsearch with specific plugins or configuration files installed on ECK, you have multiple options. Each option has its own pros and cons.

  1. Create a custom container image with the required plugins and configuration files.

  2. Use init containers to install plugins and configuration files.

  3. Use ConfigMaps or Secrets together with volumes and volume mounts for configuration files.

    • Pros

      • Best choice for injecting configuration files into your Elasticsearch nodes.
      • Follows standard Kubernetes methodology to mount files into Pods.
    • Cons

      • Not valid for plugins installation.
      • Requires to maintain the ConfigMaps or Secrets with the content of the files.

The following sections provide examples for each of the mentioned options.

Refer toCreating custom images for instructions on how to build custom Docker images based on the official Elastic images.

The following example describes option 2, using a repository plugin. To install the plugin before the Elasticsearch nodes start, use an init container to run theplugin installation tool.

spec:  nodeSets:  - name: default    count: 3    podTemplate:      spec:        initContainers:        - name: install-plugins          command:          - sh          - -c          - |            bin/elasticsearch-plugin remove --purge repository-azure            bin/elasticsearch-plugin install --batch repository-azure

When using Istio, init containers donot have network access, as the Envoy sidecar that provides network connectivity is not started yet. In this scenario, custom containers are the best option. If custom containers are simply not a viable option, then it is possible to adjust the startup command for the Elasticsearch container itself to run the plugin installation before starting Elasticsearch, as the following example describes. Note that this approach will require updating the startup command if it changes in the Elasticsearch image, which could potentially cause failures during upgrades.

spec:  nodeSets:  - name: default    count: 3    podTemplate:      spec:        containers:        - name: elasticsearch          command:          - /usr/bin/env          - bash          - -c          - |            #!/usr/bin/env bash            set -e            bin/elasticsearch-plugin remove --purge repository-s3 || true            bin/elasticsearch-plugin install --batch repository-s3            /bin/tini -- /usr/local/bin/docker-entrypoint.sh

To install custom configuration files you can:

  1. Add the configuration data into a ConfigMap or Secret.
  2. Use volumes and volume mounts in your manifest to mount the contents of the ConfigMap or Secret as files in your Elasticsearch nodes.

The next example shows how to add a synonyms file for thesynonym token filter in Elasticsearch. But you canuse the same approach for any kind of file you want to mount into the configuration directory of Elasticsearch, like adding CA certificates of external systems.

  1. Create the ConfigMap or Secret with the data:

There are multiple ways to create and mountConfigMaps andSecrets on Kubernetes. Refer to the official documentation for more details.

This example shows how to create a ConfigMap namedsynonyms with the content of a local file namedmy-synonyms.txt added into thesynonyms-elasticsearch.txt key of the ConfigMap.

kubectl create configmap synonyms -n <namespace> --from-file=my-synonyms.txt=synonyms-elasticsearch.txt
Tip

Create the ConfigMap or Secret in the same namespace where your Elasticsearch cluster runs.

  1. Declare the ConfigMap as a volume and mount it in the Elasticsearch containers.

In this example, modify your Elasticsearch manifest to mount the contents of thesynonyms ConfigMap into/usr/share/elasticsearch/config/dictionaries on the Elasticsearch nodes.

spec:  nodeSets:  - name: default    count: 3    podTemplate:      spec:        containers:        - name: elasticsearch          volumeMounts:          - name: synonyms            mountPath: /usr/share/elasticsearch/config/dictionaries        volumes:        - name: synonyms          configMap:            name: synonyms
  1. Elasticsearch runs by convention in a container calledelasticsearch. Do not change that value.
  2. Use always a path under/usr/share/elasticsearch/config.
  3. Usesecret instead ofconfigMap if you used a secret to store the data.
  4. The ConfigMap name must be the same as the ConfigMap created in the previous step.

After the changes are applied, Elasticsearch nodes should be able to accessdictionaries/synonyms-elasticsearch.txt and use it in anyconfiguration setting.


[8]ページ先頭

©2009-2026 Movatter.jp