<p>I'm using Kops 1.4.4 to launch my Kubernetes cluster on AWS. My Elasticsearch pods require me to set the kernel parameter <code>vm.max_map_count</code> to at least 262144. Kubernetes 1.5.1 has systctl feature, but it requires Docker >= 1.12. Kops currently builds my nodes with a lesser Docker version and so I'm stuck trying to figure out how to automate setting the kernel parameter. If I attempt to set it in my Dockerfile using <code>RUN sysctl -w vm.max_map_count=262144</code>, I get the error message: 'sysctl: setting key "vm.max_map_count": Read-only file system'.</p>

<p>Are there any workarounds for this?</p>

<p>Apparently this can be done using <a href="http://kubernetes.io/docs/user-guide/production-pods/#handling-initialization" rel="nofollow noreferrer">Kubernetes init containers</a>. Following the Kubernetes deployment config posted <a href="https://github.com/giantswarm/kubernetes-elastic-stack/blob/c8cda9e8efc1e33eb3cb314023edd0e91d39194a/manifests-all.yaml" rel="nofollow noreferrer">here</a> this can be done by applying the following annotation to your deployment. Under spec > template > metadata > annotations add:</p>

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