Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set ulimit for containers in Kubernetes?

Tags:

How do I set ulimit for containers in Kubernetes? (specifically ulimit -u)

like image 814
shaylevi2 Avatar asked Nov 11 '15 11:11

shaylevi2


People also ask

What is the default CPU limit set for a container?

By default, this is set to 1024. To find more options for limiting container CPU usage, please refer to Docker's official documentation.

What is the default resource limit in Kubernetes?

Kubernetes doesn't provide default resource limits out-of-the-box. This means that unless you explicitly define limits, your containers can consume unlimited CPU and memory.


2 Answers

It appears that you can't currently set a ulimit but it is an open issue: https://github.com/kubernetes/kubernetes/issues/3595

like image 66
James Brown Avatar answered Sep 18 '22 06:09

James Brown


If you are able to ssh into the kubernetes cluster, you can modify the docker.service file.

  • For an amazon EKS cluster, the file is located at /usr/lib/systemd/system/docker.service.

  • Append the property LimitMEMLOCK=Infinity in the file and then restart the docker service.

    sudo service docker restart

This would spin up docker containers with an infinite memlock value. Probably equivalent to

docker run -ulimit memlock=-1:-1 <docker image>

like image 34
nikoo28 Avatar answered Sep 21 '22 06:09

nikoo28