<p>I try to install ElasticSearch (latest) on a cluster nodes on Google Container Engine but ElasticSearch needs the variable : <code>vm.max_map_count</code> to be >= 262144.</p>

<p>If I ssh to every nodes and I manually run :</p>

<pre><code>sysctl -w vm.max_map_count=262144
</code></pre>

<p>All goes fine then, but any new node will not have the specified configuration.</p>

<p>So my questions is :</p>

<p>Is there a way to load a system configuration on every nodes at boot time ?
Deamon Set would not be the good solution because inside a docker container, the system variables are read-only.</p>

<p>I'm using a fresh created cluster with the <code>gci</code> node image.</p>

<p>I found another solution while looking at <a href="https://github.com/pires/kubernetes-elasticsearch-cluster/blob/master/es-client.yaml" rel="noreferrer" title="this repository">this repository</a>.</p>

<p>It relies on the use of <a href="https://kubernetes.io/docs/concepts/abstractions/init-containers/" rel="noreferrer">an init container</a>, the plus side is that only the init container is running with privileges:</p>

<pre><code>annotations:
    pod.beta.kubernetes.io/init-containers: '[
      {
      "name": "sysctl",
        "image": "busybox",
        "imagePullPolicy": "IfNotPresent",
        "command": ["sysctl", "-w", "vm.max_map_count=262144"],
        "securityContext": {
          "privileged": true
        }
      }
    ]'
</code></pre>

<p>There is a new syntax available since Kubernetes 1.6 which still works for 1.7. Starting with 1.8 this new syntax is required. The declaration of init containers is moved to <code>spec</code>:</p>

<pre><code>  - name: init-sysctl
    image: busybox
    command:
    - sysctl
    - -w
    - vm.max_map_count=262144
    imagePullPolicy: IfNotPresent
    securityContext:
      privileged: true
</code></pre>
