How to set up mem and CPU limit using swarmspawner?

How to set up mem and CPU limit using swarmspawner?
I set it as dockerspawnerused, but fail.How to correct set up te resource limits

Setting:

c.Spawner.mem_limit = '2G'
c.Spawner.cpu_limit = 1

in your jupyterhub_config.py should do it.

I used to set like this, but fail:
c.SwarmSpawner.resource_spec = {
‘mem_limit’ : int(32 * 1000 * 1000 * 1000),
‘mem_reservation’ : int(4 * 1000 * 1000 * 1000),

}
I will try your solution,thx

I never got extra_resources_spec to work using custom labels, so I’d just stick with mem_limit and cpu_limit, which work great.