Modify elastic.yml file in kubernetes pod


Hello! I have an elasticsearch cluster running on minikube. When I ssh into one of the elasticsearch pods, I can see that the elasticsearch.yml file is very empty/has almost no configs set.

[elasticsearch@es-0 config]$ cat elasticsearch.yml "docker-cluster"

# minimum_master_nodes need to be explicitly set when bound on a public IP
# set to 1 to allow single node clusters
# Details:
discovery.zen.minimum_master_nodes: 1 

I would like to add some modifications to this file. I know that I am supposed to use a ConfigMap to update this but I am confused as to how I can use the ConfigMap values to update the elasticsearch.yml config.

Currently this is my ConfigMap:

apiVersion: v1
kind: ConfigMap
  name: elasticsearch-config
  elasticsearch.yml: | elasticsearch-pod ${HOSTNAME}
    bootstrap.memory_lock: false
    discovery.zen.minimum_master_nodes: 2 ["es-0", "es-1", "es-2"]

Now I would like to make sure that when my StatefulSet is created the pods use this elasticsearch.yml. I know for Pods/StatefulSets you can set the env vars by referencing keys in your ConfigMap but I don't know what env vars are used by elasticsearch.

- name: ENV_VAR
              name: elasticsearch-config
              key: KEY_HERE

I can't seem to find a reference doc on the elasticsearch site, do I just use the same name (Ex. env var has key Thanks!


I found out that I can simply mount the MapConfig as a volume to the pods I want.

        - name: storage
          mountPath: /data
        - name: config-volume
          mountPath: /usr/share/elasticsearch/config
       - name: config-volume
          name: elasticsearch-config

But this results in errors when creating the pods:

2017-10-11 20:57:59,841 main ERROR Could not register mbeans access denied ("" "register")
	at java.lang.SecurityManager.checkPermission(
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(
	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(
	at org.apache.logging.log4j.core.jmx.Server.register(
	at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(
	at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(
	at org.apache.logging.log4j.core.LoggerContext.start(
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(
	at org.apache.logging.log4j.core.config.Configurator.initialize(
	at org.apache.logging.log4j.core.config.Configurator.initialize(
	at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(
	at org.elasticsearch.common.logging.LogConfigurator.configure(
	at org.elasticsearch.common.logging.LogConfigurator.configure(
	at org.elasticsearch.bootstrap.Bootstrap.init(
	at org.elasticsearch.bootstrap.Elasticsearch.init(
	at org.elasticsearch.bootstrap.Elasticsearch.execute(
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(
	at org.elasticsearch.cli.Command.main(
	at org.elasticsearch.bootstrap.Elasticsearch.main(
	at org.elasticsearch.bootstrap.Elasticsearch.main(

ERROR: no found; tried [/usr/share/elasticsearch/config] and its subdirectories

Am I mounting in the wrong spot or am I supposed to have all the required files inside my configMap? What potential issues should I look into here? Thanks!


Fixed my issue, had the same solution as the one seen here

Basically my mount was overwriting everything else in the path so I only had my elasticsearch.yml file and all the other config files were missing. Using the subPath field fixed my issue of overwriting

(system) #3

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