Infrastructure Automation with: MAAS, Juju, lxd ...

Notes on setup and configuration and issues with Canonical Juju, MAAS etc

Infrastructure Automation with: MAAS, Juju, lxd ...

Status: October 2021 - Random notes...


Canonical the company behind Ubuntu decided around Ubuntu 16 series that if it wanted to make money out of Linux then it needed to start focusing in enterprise computing.

The result was it became very focused on Canonical / Ubuntu tools to support management and creation of cloud infrastructure. These tools include:

MAAS - a machine boot strap manager that manages PXE boot process

JuJu - a machine and application deployment orchestration solution

LXD - an OS hypervisor that builds on top of LXC

Landscape - An infrastructure management tool

cloud-init -

netplan - a declarative networking configuration system

This set of tools is both complex as it is managing a complicated process, but also has an underlying architecture simplicity in how the parts bolt together. The tools are also under going signficant development, so things do then to break or change a bit...

These are my note on using the various tools.


Getting into JuJu LXD controller

Generally you should not need to ssh'ed into Juju LXD controller machine as these are created and managed for you automatically.

I have found that after you upgrade a machine with a local Juju controller install as LXD machine, that you loose the abilty to connect to the controller and hence your juju envrionment gets stranded.

The official way to connect to Juju controller is by:

  • "juju ssh 0" - where 0 is your default controller

But if the IP address the LXD machine has changed then this will fail.

To see the address that JuJu is trying to connect to use "--debug" switch on all your "juju" commands

you can access the controller by doing:

  • "lxc list" - to get the name of your controller
  • "lxc shell <LXC-NAME>" - this will get you into shell of LXC machine and you can look at its configuration. Once in the machine it just looks like another linux box.

As a hack you can force the LXD machine to have expect JuJu IP address by editing the "/etc/netplan/50-cloud-init.yaml" file and doing: "netplan apply"

Check to see if JuJu API socket is open for listening: "lsof -i -P -n | grep LISTEN"

Other lxc commands include:

  • "lxc stop <LXC-NAME>" - to stop the container
  • "lxc start <LXC-NAME>" - to start the container
  • lxc delete <LXC-NAME>" - to delete the container

Multi-Cloud JuJu with LXD Controller

By default Juju will consume a machine per controller and a given controller will manage a single cloud. This is very inefficient when you have limited physical infrastructure and to avoid this you should become famillar with JuJu "Multi-Cloud" management capabilities.

This allow you to bootstrap a single controller and then add multiple cloud to it. When you add a model specifying the cloud controls where it will be deployed:

$ juju add-cloud --local
$ juju add-credential <MAAS>
$ juju clouds
$ juju controllers
$ juju add-cloud --controller <LOCAL-LXD> <MAAS>
$ juju add-model <NAME> <MAAS>
$ juju deploy charmed-kubernetes


JuJu API Server not running


LXD Networking

Since Ubuntu 17 network has been managed via netplan. When you setup LXD you  will need to specify the bridge that this will use to connect the LXC machines to. By convention this bridge has the name "lxdbr0" (for lxd bridge 0).

If you want to set up a local LXD Juju controller then you should first configure, the lxdbr0 bridge via netplan, then do setup lxd and then setup juju.

Having setup the lxd bridge then do lxd init and reference the bridge: "sudo lxd init"

$ sudo lxd init
[sudo] password for XXX: 
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: lxdbr0
Would you like the LXD server to be available over the network? (yes/no) [default=no]: yes
Address to bind LXD to (not including port) [default=all]: 
Port to bind LXD to [default=8443]: 
Trust password for new clients: 
Again: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] yes
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 


References & Links:

LXD Networking - LXD bridge explained  and newer LXD 2.3 network management article on LXD.

How to SSH into LXD - seems others have needed to do this ... so they "Asked Ubuntu"

Multi-cloud Controllers - Adding Multi-Cloud support into Juju Controller and article on this


JuJu Doll Picture - from "Creole Moon", as somethings it seems getting this stuff going is a bit like black magic...