Skip to content

Commit 51ad4b1

Browse files
committed
plugins and config files updated
1 parent 42b2239 commit 51ad4b1

File tree

1 file changed

+69
-27
lines changed

1 file changed

+69
-27
lines changed

deploy-manage/deploy/cloud-on-k8s/custom-configuration-files-plugins.md

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mapped_pages:
77

88
# Custom configuration files and plugins [k8s-bundles-plugins]
99

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

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

@@ -35,9 +35,26 @@ To run Elasticsearch with specific plugins or configuration files installed on E
3535
* Each Elasticsearch node needs to repeat the download, wasting bandwidth and slowing startup.
3636
* Deployment manifests are more complicated.
3737

38+
3. Use ConfigMaps or Secrets together with volumes and volume mounts for configuration files.
39+
40+
* **Pros**
41+
42+
* Best choice for injecting configuration files into your {{es}} nodes.
43+
* Follows standard Kubernetes methodology to mount files into Pods.
44+
45+
* **Cons**
46+
47+
* Not valid for plugins installation.
48+
* Requires to maintain the ConfigMaps or Secrets with the content of the files.
49+
50+
The following sections provide examples for each of the mentioned options.
51+
52+
## Create a custom image
3853

3954
Refer to [Creating custom images](create-custom-images.md) for instructions on how to build custom Docker images based on the official Elastic images.
4055

56+
## Use init containers for plugins installation
57+
4158
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 the [plugin installation tool](https://www.elastic.co/guide/en/elasticsearch/plugins/current/installation.html).
4259

4360
```yaml
@@ -57,9 +74,9 @@ spec:
5774
bin/elasticsearch-plugin install --batch repository-azure
5875
```
5976
60-
To install custom configuration files you can use volumes and volume mounts.
77+
### Note when using Istio [istio-note]
6178
62-
The next example shows how to add a synonyms file for the [synonym token filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html) in Elasticsearch. But you can use the same approach for any kind of file you want to mount into the configuration directory of Elasticsearch.
79+
When using Istio, init containers do **not** 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.
6380
6481
```yaml
6582
spec:
@@ -69,24 +86,45 @@ spec:
6986
podTemplate:
7087
spec:
7188
containers:
72-
- name: elasticsearch <1>
73-
volumeMounts:
74-
- name: synonyms
75-
mountPath: /usr/share/elasticsearch/config/dictionaries
76-
volumes:
77-
- name: synonyms
78-
configMap:
79-
name: synonyms <2>
89+
- name: elasticsearch
90+
command:
91+
- /usr/bin/env
92+
- bash
93+
- -c
94+
- |
95+
#!/usr/bin/env bash
96+
set -e
97+
bin/elasticsearch-plugin remove --purge repository-s3 || true
98+
bin/elasticsearch-plugin install --batch repository-s3
99+
/bin/tini -- /usr/local/bin/docker-entrypoint.sh
80100
```
81101
82-
1. Elasticsearch runs by convention in a container called *elasticsearch*.
83-
2. Assuming you have created a config map in the same namespace as Elasticsearch with the name *synonyms* containing the synonyms file(s).
102+
## Use a volume and volume mount together with a ConfigMap or Secret
84103
104+
To install custom configuration files you can:
85105
86-
$$$istio-note$$$
87-
**Note when using Istio**
106+
1. Add the configuration data into a ConfigMap or Secret.
107+
2. Use volumes and volume mounts in your manifest to mount the contents of the ConfigMap or Secret as files in your {{es}} nodes.
88108
89-
When using Istio, init containers do **not** 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.
109+
The next example shows how to add a synonyms file for the [synonym token filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html) 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.
110+
111+
1. Create the ConfigMap or Secret with the data:
112+
113+
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.
114+
115+
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.
116+
117+
```sh
118+
kubectl create configmap synonyms -n <namespace> --from-file=my-synonyms.txt=synonyms-elasticsearch.txt
119+
```
120+
121+
::::{tip}
122+
Create the ConfigMap or Secret in the same namespace where your {{es}} cluster runs.
123+
::::
124+
125+
2. Declare the ConfigMap as a volume and mount it in the Elasticsearch containers.
126+
127+
In this example, modify your {{es}} manifest to mount the contents of the `synonyms` ConfigMap into `/usr/share/elasticsearch/config/dictionaries` on the {{es}} nodes.
90128

91129
```yaml
92130
spec:
@@ -96,15 +134,19 @@ spec:
96134
podTemplate:
97135
spec:
98136
containers:
99-
- name: elasticsearch
100-
command:
101-
- /usr/bin/env
102-
- bash
103-
- -c
104-
- |
105-
#!/usr/bin/env bash
106-
set -e
107-
bin/elasticsearch-plugin remove --purge repository-s3 || true
108-
bin/elasticsearch-plugin install --batch repository-s3
109-
/bin/tini -- /usr/local/bin/docker-entrypoint.sh
137+
- name: elasticsearch <1>
138+
volumeMounts:
139+
- name: synonyms
140+
mountPath: /usr/share/elasticsearch/config/dictionaries <2>
141+
volumes:
142+
- name: synonyms
143+
configMap: <3>
144+
name: synonyms <4>
110145
```
146+
147+
1. Elasticsearch runs by convention in a container called `elasticsearch`. Do not change that value.
148+
2. Use always a path under `/usr/share/elasticsearch/config`.
149+
3. Use `secret` instead of `configMap` if you used a secret to store the data.
150+
4. The ConfigMap name must be the same as the ConfigMap created in the previous step.
151+
152+
After the changes are applied, {{es}} nodes should be able to access `dictionaries/synonyms-elasticsearch.txt` and use it in any [configuration setting](./node-configuration.md).

0 commit comments

Comments
 (0)