Is there a way to tell LXD to create containers under a custom cgroup controller?

I have a use case where i would like some 20 containers to share a limited pool of resources (cpu,ram,etc) .

Such that you have 10 containers sharing their workload accross 5 CPUs but with no specific cpu limit for every container

I know that i can use a project to set limits for

Maximum value for the sum of individual “limits.cpu” configs set on the instances of the project

but i am looking for something more flexible and similar to putting the containers in their own (process free) cgroup and just setting the limits in the parent cgroup.

I have 2 questions:

  • Is there an easier way to achieve this?
  • Is there a way to tell LXD to put a container inside a custom parent cgroup?

You could nest several containers inside single resource restricted LXD container.

1 Like

In case anyone else is looking for this.

LXC supports custom locations for it’s container
s cgroups directories. See cgroup_advanced_isolation

So you can just tell lxd via the raw.lxc option to place the container’s cgroup under your own custom cgroup controller.

And there is ofc the much simpler answer by @tomp which in effect works the same way but adds the complexity of managing another lxd instance.

1 Like