Can I set ulimit for containers in k8s?

+1 vote

Any way i can set ulimit for containers in kubernetes?

Sep 14, 2018 in Kubernetes by shubham
• 6,910 points
3,275 views

4 answers to this question.

+1 vote

Since we use docker mostly for single processes, so there hasn't been an actual need for ulimit -u on it. On the other hand if you're just looking for resource limiting, kubernetes lets you do that. You can follow this doc:

https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/admin/resource-quota.md

answered Sep 14, 2018 by ajs3033
• 7,280 points
+1 vote

ssh into your Kubernetes cluster and 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 docker using the following command

sudo service docker restart

This will spin up docker containers with an infinity memlock which is equivalent to

docker run -ulimit memlock=-1:-1 <docker image>
answered May 7, 2019 by Umer
+1 vote

You can set a DaemonSet with a privileged container setting the hosts ulimit. Something like this:

Example:

    image: image-name
    command: ["sh", "-c", "ulimit -n 65536"]
    securityContext:
      privileged: true
answered May 7, 2019 by Alok
+1 vote

You can either modify them via UserData for worker AutoScalingGroup (when using EKS AMI) or by building your own AMI.

Something like:

sudo sed -i "s|ExecStart=.*|ExecStart=/usr/bin/dockerd --default-ulimit memlock=83968000:83968000|g" /usr/lib/systemd/system/docker.service

sudo systemctl restart docker.service
answered May 7, 2019 by Inayat

Related Questions In Kubernetes

0 votes
1 answer

Can I run docker containers on different machines?

Yes, but you should also: create the relevant libnetworks in ...READ MORE

answered Oct 17, 2018 in Kubernetes by lina
• 8,180 points
50 views
0 votes
1 answer

How do I set up a k8s cluster on windows?

Hey @Nadia, follow these steps to create ...READ MORE

answered Feb 25, 2019 in Kubernetes by Roshan
50 views
0 votes
1 answer

Can I configure my kubernetes job to run for a specified time?

When we create a job spec, we ...READ MORE

answered Jul 17, 2019 in Kubernetes by Sirajul
• 45,310 points
35 views
0 votes
1 answer

how can i access two containers that are inside a pod from the browser with IP address?

Just do port forward. kubectl port-forward [nginx-pod-name] 80:80 kubectl ...READ MORE

answered Jul 18, 2019 in Kubernetes by Sirajul
• 45,310 points
76 views
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
1,100 views
0 votes
2 answers

Using a local image to create a pod in K8s

I'm not sure but you can try ...READ MORE

answered Apr 29, 2019 in Kubernetes by Vishaka
7,331 views
0 votes
2 answers