MicroK8s Ulimit Configuration
Exceeding the Open Files Limit
When deploying applications to MicroK8s on Mac OSX, you may encounter an error when the application attempts to open too many files.
ElasticSearch displays this error:
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
CouchBase displays this error:
The maximum number of open files for the couchbase user is set too low (65536).
It must be at least 70000.Normally this can be increased by adding the following lines to
/etc/security/limits.conf:couchbase soft nofile <value>
couchbase hard nofile <value>
Raising the ulimit on the MicroK8s node will resolve these file descriptor limit errors.
Containerd in MicroK8s
MicroK8s uses containerd to run containers. The MicroK8s service configuration for containerd has a setting that controls the ulimit for all containers in the Kubernetes cluster.
Modifying Containerd Ulimit
Login to MicroK8s node (Mac uses multipass VMs):
$ multipass shell microk8s-vm
Last login: Thu Jul 16 21:24:36 2020 from 192.168.64.1
ubuntu@microk8s-vm:~$
Edit /var/snap/microk8s/current/args/containerd-env.
$ vi /var/snap/microk8s/current/args/containerd-env
Search for the line that has the ulimit -n
setting (near the bottom of the file). Change the setting to the desired value.
ulimit -n 65536
Restart microk8s:
# Exit microk8s VM shell
ubuntu@microk8s-vm:~$ exit$ microk8s stop
Stopped.
$ multipass start microk8s-vm
Starting microk8s-vm
$ microk8s start
Started.