How do I set ulimit for containers in Kubernetes?

懵懂的女人 提交于 2019-12-29 06:10:44

问题


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


回答1:


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




回答2:


Considering Docker is designed for single processes for the most part ulimit -u doesn't exactly make sense. However, if you are looking for resource limiting in general, Kubernetes allows you to set a quota on a resource. Here are the docs: https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/admin/resource-quota.md. This way you specify number of cores/memory/disk usage.




回答3:


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>




回答4:


In Kubernetes cluster (AWS EKS) you can change the ulimit for a docker container by modifying the /etc/docker/daemon.json in the node where your container is running.

Add following lines to /etc/docker/daemon.json

"default-ulimits": { "nofile": { "Name": "nofile", "Hard": 128000, "Soft": 128000 } }

and finally restart the docker service on that node by executing following command.

service docker restart



来源:https://stackoverflow.com/questions/33649192/how-do-i-set-ulimit-for-containers-in-kubernetes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!