Init containers for plugin downloads
You can install custom plugins before the Elasticsearch container starts with an initContainer. For example:
spec:
nodeSets:
- name: default
count: 3
podTemplate:
spec:
initContainers:
- name: install-plugins
command:
- sh
- -c
- |
bin/elasticsearch-plugin remove --purge analysis-icu
bin/elasticsearch-plugin install --batch analysis-icu
You can also override the Elasticsearch container image to use your own image with the plugins already installed, as described in Create custom images. For more information on both options, refer to Add plugins and configuration files in Elastic Cloud on Kubernetes and the Kubernetes documentation on init containers.
The init container inherits:
- The image of the main container image, if one is not explicitly set.
- The volume mounts from the main container unless a volume mount with the same name and mount path is present in the init container definition
- The Pod name and IP address environment variables.
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.
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