[elasticsearch] recommended method to automate an api call (e.g. ILM) post deployment?
See original GitHub issueThis is helm related so I am not asking in the ES forum.
I would like to automate the following api call:
PUT _template/my_template
{
"index_patterns": [
"logstash-*"
],
"settings": {
"number_of_shards": 8,
"number_of_replicas": 1
}
}
I am trying with these values in the helm chart, essentially the idea is to wait until the ES cluster has started (relies heavily on health check mechanism that creates the “start file”)… is this a recommended approach?
lifecycle:
postStart:
exec:
command:
- sh
- -c
- |
#!/bin/sh
# Add a template to adjust number of shards/replicas
TEMPLATE_NAME=my_template
START_FILE=/tmp/.es_start_file
INDEX_PATTERN="logstash-*"
SHARD_COUNT=8
REPLICA_COUNT=1
while [ ! -f ${START_FILE} ]; do
sleep 1
done
curl -XPUT "http://localhost:9200/_template/$TEMPLATE_NAME" -H 'Content-Type: application/json' -d'{"index_patterns":['"$INDEX_PATTERN"'],"settings":{"number_of_shards":'$SHARD_COUNT',"number_of_replicas":'$REPLICA_COUNT'}}'
FWIW have not gotten it to work yet, pod remains in Initialization phase:
elasticsearch-master-2 0/1 PodInitializing 0 12m8s
But let me know if I am on the right track please.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Tutorial: Automate rollover with ILM | Elasticsearch Guide [8.5]
To automate rollover and management of a data stream with ILM, you: ... For example, the following request creates the timeseries data stream...
Read more >REST APIs | Elasticsearch Guide [8.5] | Elastic
Elasticsearch exposes REST APIs that are used by the UI components and can be called directly to configure and access Elasticsearch features.
Read more >Create or update lifecycle policy API | Elasticsearch Guide [8.5]
ILM performs operations as the user who last updated the policy. ILM only has the roles assigned to the user at the time...
Read more >API calls | Elastic Cloud Enterprise Reference [3.5]
You use these four request methods to communicate with the Elastic Cloud Enterprise RESTful API: To fetch information: GET; To add new information:...
Read more >Rollover API | Elasticsearch Guide [master] | Elastic
We recommend using ILM's rollover action to automate rollovers. ... For example, if you roll over an alias with a current index of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://helm.sh/docs/topics/charts_hooks/
Helm hooks are the best way to do this IMO, but these helm charts dont have any extension point built in for it.
edit- sorry, didn’t realize you were running from the ES pod
In your wait loop, instead of waiting for that file, wait for the api to return a 200 before you issue the PUT command- I’d guess its a race condition.
https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#discussion
Thanks @pbecotte,
I like the idea of removing the dependency on that file, so I’ve tried:
Which seems like a sufficient solution.