<p>I'm new in kubernetes and I'm trying to deploy an elasticsearch on it.
Currently, I have a problem with the number of file descriptor required by elasticsearch and allow by docker.</p>

<pre><code>[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
</code></pre>

<p>So to fix that I have tried 3 different ways:</p>

<h1>way 1</h1>

<p>From the docker documentation, dockerd should use the system value as default value.</p>

<ol>
<li>set <code>/etc/security/limits.con</code>f with <code>* - nofile 65536</code></li>
<li>reboot</li>
<li>execute <code>ulimit -Hn &amp;&amp; ulimit -Sn</code> return return 65536 twice</li>
<li>execute <code>docker run --rm centos:7 /bin/bash -c 'ulimit -Hn &amp;&amp; ulimit -Sn'</code> (should return 65536 twice but no, return 4096 and 1024 )</li>
</ol>

<h1>way 2</h1>

<ol>
<li>add <code>--default-ulimit nofile=65536:65536</code> to <code>/var/snap/microk8s/current/args/dockerd</code></li>
<li>reboot</li>
<li>execute <code>docker run --rm centos:7 /bin/bash -c 'ulimit -Hn &amp;&amp; ulimit -Sn'</code> (should return 65536 twice but no return 4096 and 1024)</li>
</ol>

<h1>way 3</h1>

<ol>
<li><p>add </p>

<p>"default-ulimit" : {
        "nofile":{
            "Name":" nofile",
            "Hard":" 65536",
            "Soft":" 65536"
    }
}</p>

<p>to <code>/var/snap/microk8s/354/args/docker-daemon.json</code></p></li>
<li>execute <code>systemctl restart  snap.microk8s.daemon-docker.service</code></li>
<li>execute <code>journalctl -u snap.microk8s.daemon-docker.service -f</code> will return <code>unable to configure the Docker daemon with file /var/snap/microk8s/354/args/docker-daemon.json: the following directives don't match any configuration option: nofile</code> </li>
</ol>

<p>The only way I found for set the ulimit is to pass <code>--ulimit nofile=65536:65536</code> to the docker run command. But I cannot do that inside my kubernetes statesfullset config.</p>

<p>So do you know how I can solve this problem ?
I didn't somethings wrong here ?</p>

<p>Thanks in advance for your help</p>

<p>ps: I'm on ubuntu 18.0.1 with docker 18.06.1-ce and microk8s installed with snap</p>

<p>A bit late but if someone has this problem too, you can add this line to <code>/var/snap/microk8s/current/args/containerd-env</code>:</p>

<pre><code>ulimit -n 65536
</code></pre>

<p>Then stop/start microk8s to enable this fix. If you execute command <code>docker run --rm centos:7 /bin/bash -c 'ulimit -Hn &amp;&amp; ulimit -Sn'</code> you can see 65536 twice</p>

<p>More information on Microk8s Github issue <a href="https://github.com/ubuntu/microk8s/issues/253" rel="nofollow noreferrer">#253</a>. Microk8s has merge a fix for this, it may will be soon available on a release.</p>
