﻿---
title: Custom configuration files and plugins
description: Install Elasticsearch plugins with a custom image, or mount configuration files with ConfigMaps or Secrets on ECK.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7959/deploy-manage/plugins-and-bundles/cloud-on-k8s/custom-configuration-files-plugins
products:
  - Elastic Cloud on Kubernetes
applies_to:
  - Elastic Cloud on Kubernetes: Generally available
---

# Custom configuration files and plugins
This page covers two of the approaches described in [Add plugins and configuration files in Elastic Cloud on Kubernetes](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7959/deploy-manage/plugins-and-bundles/cloud-on-k8s/manage-plugins): including Elasticsearch plugins in a custom container image, and injecting configuration files with ConfigMaps or Secrets.

## Create a custom image

Refer to [Creating custom images](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7959/deploy-manage/deploy/cloud-on-k8s/create-custom-images) for instructions on how to build custom Docker images based on the official Elastic images. Install the plugins you need in the image so they are available when the Elasticsearch container starts.

## Use a volume and volume mount together with a ConfigMap or Secret

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 the [synonym token filter](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/text-analysis/analysis-synonym-tokenfilter) in Elasticsearch. But you can **use 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 mount [ConfigMaps](https://kubernetes.io/docs/concepts/configuration/configmap/) and [Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) on Kubernetes. Refer to the official documentation for more details.
This example shows how to create a ConfigMap named `synonyms` with the content of a local file named `my-synonyms.txt` added into the `synonyms-elasticsearch.txt` key of the ConfigMap.
```sh
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.
</tip>

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 the `synonyms` ConfigMap into `/usr/share/elasticsearch/config/dictionaries` on the Elasticsearch nodes.
```yaml
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 
```

After the changes are applied, Elasticsearch nodes should be able to access `dictionaries/synonyms-elasticsearch.txt` and use it in any [configuration setting](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7959/deploy-manage/deploy/cloud-on-k8s/node-configuration).
<note>
  ConfigMaps and Secrets are for configuration files only. Mounting plugin files does not install them. To install plugins, use a [custom image](#create-a-custom-image) or [init containers](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/7959/deploy-manage/plugins-and-bundles/cloud-on-k8s/init-containers-for-plugin-downloads).
</note>