Adding Shard Allocation Awareness by Zone in the Helm chart

I am testing the OD Helm chart that can be found here: opendistro-build/helm at main · opendistro-for-elasticsearch/opendistro-build · GitHub

The default supported functionalities like rolling out Master and Data nodes work fine within a single zone, and configuring affinity by creating each node type on dedicated k8s nodes (VMs) also work.

Now I want to go to the next step of configuring the ES nodes into multiple zones. I have set-up a node pool in 2 zones. The way to achieve this is by adding to the elasticsearch.yaml on each ES node. The value of should be the name of the zone of the k8s node where the pod is being created. Then we need to add to each master node or apply as cluster setting the cluster.routing.allocation.awareness.attributes: zone. And then we are done! How to achieve this with this helm chart?

Another repo discussed this issue and there is a workaround solution offered by using initContainers, see Dynamic pod configuration within a nodeSet for zone awareness · Issue #3933 · elastic/cloud-on-k8s · GitHub

The commands that need to be run in the initContainer are these:

ZONE=$(kubectl get node $NODE_NAME -o json | jq -r '.metadata.labels[\"failure-\"]') \
CONFIG_FILE=/usr/share/elasticsearch/config/elasticsearch.yml \
CONFIG_FILE_BACKUP=/usr/share/elasticsearch/config/elasticsearch.yml.backup; \

I tried this solution, but I am getting RBAC issues. And when starting this initContainer, the elasticsearch.yaml file cannot be found either. Has anyone else tried? I would really like to use Helm for this, instead of explictly creating multiple deployments for each zone.

What exact issue are seeing when you say RBAC issue? How are you attaching the elasticsearch.yml? configmap? baked into the image or setting up on a persistent volume?

I fixed these issues and finally got the shard allocation awareness working with this Helm chart.

I had to add an extra ClusterRoleBinding for the service.
For the node attributes I have used environment variables instead to bypass the issue of not being able to write to the elasticsearch.yml file.

I will polish things up and create a PR on GH. I am looking forward to get some feedback about the solution.

1 Like