How to set constraints for a machine

Constraints at the machine level can be set when adding a machine with the add-machine command. Doing so provides a way to override defaults at the all-units, application, model, and all-models levels.

Once such a machine has been provisioned, it can be used for an initial deployment (deploy) or a scale-out deployment (add-unit). See Deploying to specific machines for the command syntax to use.

A machine with a constraint can be added in this way:

juju add-machine --constraints arch=arm

To add a machine that is connected to a space, for example storage, run:

juju add-machine --constraints spaces=storage

If a space constraint is prefixed by ‘^’, then the machine will not be connected to that space. For example, the command below will result in an instance that is connected to both the db-space and internal spaces but not connected to either the storage or dmz spaces.

--constraints spaces=db-space,^storage,^dmz,internal

See the network spaces page for details on spaces.

For a LXD cloud, to create a machine limited to two CPUs:

juju add-machine --constraints cores=2

To add eight Xenial machines such that they are evenly distributed among four availability zones:

juju add-machine -n 8 --series xenial --constraints zones=us-east-1a,us-east-1b,us-east-1c,us-east-1d

Last updated 5 months ago.