简体   繁体   中英

How can I edit elasticsearch.yml on kubernetes pods, with a statefulset, or something similar?

I have to edit elasticsearch.yml in order to create a backup (setting the path.repo like this is necessary): path.repo: /mnt/backup

But I have elasticsearch running on Kubernetes, and I would like to set the path.repo from a statefulset or something similar to all pods at the same time. Can anyone tell me how to do that? Thanks

I tried to do this with configmap like this: https://discuss.elastic.co/t/modify-elastic-yml-file-in-kubernetes-pod/103612

but when I restarted the pod it threw an error: /usr/share/elasticsearch/bin/run.sh: line 28: ./config/elasticsearch.yml: Read-only file system

ConfigMaps are mounted to pods as read-only filesystems, this behavior cannot be changed.

If you want to be able to modify config once for all pods then you have to mount config/ directory as a ReadWriteMany persistent volume (NFS, GlusterFS and so on).

I just realized, that you don't even have to edit elasticsearch.yml to set the path.repo setting, you can add it as an enviromental variable in your statefulset like this:

env:
- name: path.repo
  value: "/mnt/backup"

In version 6.8 the config file is in a secret. I was unable to change the secret to update the base64 encoded configuration. However, apparently the way to configure it is to set it as documented here:

https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-node-configuration.html

the yaml file is the one that can be found under Object Browser:

screenshot object browser

from the command line you can use:

kubectl get -o yaml Elasticsearch elasticsearch-name-of-your-deployment > your.yml

Then mod it and apply it with

kubectl apply -f your.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM