See also: How to manage machines
This definition suggests that, regardless of whether the cloud is bare metal cloud, a virtual machine cloud, or a LXD container- or VM-based cloud, and regardless of whether the command targets a regular instance or rather a LXD container on a regular instance (all the commands above can apply to both), what’s being provisioned is always, from the point of view of Juju, a ‘machine’.
From the point of view of an end user, this is absolutely true, with one small caveat – even though listed in
juju outputs under ‘Machines’, and in general handled via the same CLI commads as a machine, a LXD container provisioned on top of a regular cloud instance will be named after its host machine; e.g.,
0/lxd/5 = LXD container
5 on machine
When you deploy an application on a machine, there is usually one unit per machine. However, it is usually possible to optimise resources by deploying multiple units of the same or of different applications to the same machine.
In Juju, they are both essentially the same – ‘machines’. For example, most Juju CLI commands that target machines can actually target system containers in the exact same way.
Expand to view an example
juju add-machine lxd starts a LXD container on a new machine and adds both as ‘machines’ – the only difference being that the container ‘machine’ is prefixed with the ID of its host machine and the annotation
$ juju add-machine lxd created container 1/lxd/0 $ juju machines Machine State Address Inst id Base AZ Message 0 started 10.154.118.110 juju-dadfb7-0 email@example.com Running 1 pending pending firstname.lastname@example.org Creating container 1/lxd/0 pending pending email@example.com
And if you then deploy an application to a LXD container (without specifying any particular container), that will again provision two machines:
$ juju deploy postgresql --to lxd Located charm "postgresql" in charm-hub, revision 288 Deploying "postgresql" from charm-hub charm "postgresql", revision 288 in channel 14/stable on firstname.lastname@example.org/stable ubuntu@charm-dev:~/.local/share/juju$ juju machines Machine State Address Inst id Base AZ Message 0 started 10.154.118.110 juju-dadfb7-0 email@example.com Running 1 started 10.154.118.72 juju-dadfb7-1 firstname.lastname@example.org Running 1/lxd/0 pending juju-dadfb7-1-lxd-0 email@example.com Container started 2 started 10.154.118.209 juju-dadfb7-2 firstname.lastname@example.org Running 2/lxd/0 pending pending email@example.com acquiring LXD image
In Juju, many different commands have a machine argument. The shape of this argument depends on whether the machine is existing vs. new and a regular cloud instance vs. a LXD container on top of a regular cloud instance. The argument can also contain combinations, in comma-separated format. The examples below illustrate all the various cases:
|shape of the machine argument||meaning|
|a new machine|
||machines 0 and 4|
||a new LXD container on a new machine|
||a new LXD container on machine 25|
||machine 3, LXD container 2 on machine 0, and a new LXD container on machine 5|
Last updated a month ago.