Container constraints (limits) now supported

Using Juju to deploy a Kubernetes charm, you can now specify resource limits for memory and cpu. The cpu units are milli cpu. The standard Juju constraint syntax is used.

Note: right now, the constraint values are mapped to resource limits. There’s no support for resource requests. This conforms to the behaviour of LXD constraints.

Example

juju deploy mariadb-k8s --constraints "mem=4G cpu-power=500"

1 Like

In the linked text, it seems that if you wanted to specify “milli” you would pass a little “m”. So 1 would imply 1 CPU, while 1m would be 1/1000 of a CPU. With the intent that the granularity that you can supply is 1/1000. Do you translate 500 to 500m internally? Or do you just pass the value that the user supplies directly to K8s?

The cpu value specified via the --constraints arg is an int, and the implicit unit is “milli CPUs”.
K8s requires a value plus unit, so 500 is translated to “500m” to pass to Kubernetes.

Note that, following set-constraints on an already-deployed application, resource limits are not updated on the k8s side until the next pod-spec-set or scale-application.

1 Like