<p>I want to configure elasticsearch with the elasticsearch.yml, located in /usr/share/elasticsearch/config. I am doing this via a ConfigMap which I mount into the container.</p>

<p>That does not work due to k8s takes over the control of this directory and the other files of that directory does not exist anymore (eg jvm.options).</p>

<p>I think that is a common issue - is there a best practice to fix this? The first idea which came to my mind was symlinking to /some/other/directory/elasticsearch.yml with an initcontainer. Is that wise to do so?</p>

<p>So found a proper solution I want to share with you. The magic happens with the subPath in the volumeMount</p>

<pre><code>apiVersion: v1
kind: ConfigMap
...
data:
  elasticsearch.yml: |
    xpack.license.self_generated.type: basic
---
apiVersion: extensions/v1beta1
kind: Deployment
...
spec:
  ...
  template:
    containers:
      ...
    volumeMounts:
      - name: config
        mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
        subPath: elasticsearch.yml
  volumes:
    - name: config
      configMap:
        name: elasticsearch-logging
</code></pre>
