Pass ulimit to dockerd

1/4/2019

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.

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

So to fix that I have tried 3 different ways:

way 1

From the docker documentation, dockerd should use the system value as default value.

  1. set /etc/security/limits.conf with * - nofile 65536
  2. reboot
  3. execute ulimit -Hn && ulimit -Sn return return 65536 twice
  4. execute docker run --rm centos:7 /bin/bash -c 'ulimit -Hn && ulimit -Sn' (should return 65536 twice but no, return 4096 and 1024 )

way 2

  1. add --default-ulimit nofile=65536:65536 to /var/snap/microk8s/current/args/dockerd
  2. reboot
  3. execute docker run --rm centos:7 /bin/bash -c 'ulimit -Hn && ulimit -Sn' (should return 65536 twice but no return 4096 and 1024)

way 3

  1. add

    "default-ulimit" : { "nofile":{ "Name":" nofile", "Hard":" 65536", "Soft":" 65536" } }

    to /var/snap/microk8s/354/args/docker-daemon.json

  2. execute systemctl restart snap.microk8s.daemon-docker.service

  3. execute journalctl -u snap.microk8s.daemon-docker.service -f will return 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

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

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

Thanks in advance for your help

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

-- David
docker
elasticsearch
kubernetes
ulimit

1 Answer

7/15/2019

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

ulimit -n 65536

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

More information on Microk8s Github issue #253. Microk8s has merge a fix for this, it may will be soon available on a release.

-- Starfight
Source: StackOverflow