Installing Elasticsearch plugins when ES is running as Kubernetes pod

I understand that one method is to use the

containers:
command: Required command

But this data is not retained once the pod restarts and the command is run again and again resulting in a crashloopbackoff. How to resolve this?

here's my deployment file for reference

apiVersion: apps/v1
kind: Deployment
metadata:
name: elastic-deployment
labels:
app: elastic
spec:
replicas: 1
selector:
matchLabels:
app: elastic
template:
metadata:
labels:
app: elastic
spec:
containers:
- name: elastic
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
ports:
- containerPort: 9200
- containerPort: 9300
env:
- name: discovery.type
value: "single-node"
command:
- "/bin/bash"
- "-c"
- |
/usr/share/elasticsearch/bin/elasticsearch-plugin install mapper-size
volumeMounts:
- name: storage
mountPath: /usr/share/elasticsearch/data
volumes:
- name: storage
persistentVolumeClaim:
claimName: task-pv-claim

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.