How do I set ulimit for containers in Kubernetes?

2020-02-10 03:39发布

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

4条回答
趁早两清
2楼-- · 2020-02-10 04:11

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楼-- · 2020-02-10 04:13

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楼-- · 2020-02-10 04:13

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

查看更多
萌系小妹纸
5楼-- · 2020-02-10 04:30

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

查看更多
登录 后发表回答