systemk icon indicating copy to clipboard operation
systemk copied to clipboard

Resource requests and limits

Open miekg opened this issue 4 years ago • 5 comments

systemd has both mem and cpu accounting. The memory is specified in bytes and can be used from the podspec as is. The cpu however is done differently than in k8s. See https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html

The problem is how to translate the cpu in the podspec into systemd values.

miekg avatar Dec 21 '20 09:12 miekg

Here's the possible formats for Pod CPU resource requests and limits:

  • an integer value, such as 2
  • a fraction, such as 0.1
  • an integer value in millis, such as 500m

All formats can be present in the same Pod spec and are directly translatable to milliseconds, which is supported by CPUQuotaPeriodSec, eg:

  • 2 == 2.0 == 2000m
  • 0.1 == 100m

Do you see any limitation of just going w/ that attribute?

pires avatar Jan 11 '21 10:01 pires

[ Quoting [email protected] in "Re: [virtual-kubelet/systemk] Resou..." ]

Here's the possible formats for Pod CPU resource requests and limits:

• an integer value, such as 2 • a fraction, such as 0.1 • an integer value in millis, such as 500m

All formats can be present in the same Pod spec and are directly translatable to milliseconds, which is supported by CPUQuotaPeriodSec, eg:

• 2 == 2.0 == 2000m • 0.1 == 100m

Do you see any limitation of just going w/ that attribute?

nope, if you say these are compatible it's pretty easy to convert and use.

miekg avatar Jan 11 '21 11:01 miekg

Actually, I got it wrong when it comes to systemd primitives. CPUQuota is the field to use and it supports percentage alone. The conversion should be trivial, though.

Now, this only covers resource limits and not requests.

pires avatar Jan 11 '21 12:01 pires

[ Quoting [email protected] in "Re: [virtual-kubelet/systemk] Resou..." ]

Actually, I got it wrong when it comes to systemd primitives. CPUQuota is the field to use and it supports percentage alone. The conversion should be trivial, though.

Now, this only covers resource limits and not requests.

don't think we can do requests though?

We'll also need to enable the CPU and memory accounting

miekg avatar Jan 11 '21 12:01 miekg

One problem I see is that it seems that enabling accounting for one slice means parent and child slices are affected too which may not be desirable.

pires avatar Jan 11 '21 13:01 pires