LXD host part from a cluster and singleton

Hi guys,

Is it possible for an LXD host to be in a cluster and running as well as a singleton?

Here is my case. I have 10 dedicated servers. On server1 to install ubuntu OS, on top LXD singleton, and MAAS as lxd container. Deploy the rest of the servers( 9 servers) with MAAS. After that to create an LXD cluster with all 10 servers and move MAAS lxd container into the cluster.

Standalone LXD servers can’t join a cluster without being wiped clean first, but that’s luckily not what you’re doing in this case.

In your case, you’re starting from a standalone LXD server which then gets turned into the initial cluster member and the cluster then gets grown to 10 servers total. That works perfectly fine.

You can either bootstrap that initial LXD server as a cluster right from the start (a single server cluster effectively) then deploy your MAAS container on it, deploy the other servers and then join those other servers into the cluster.

Or you can not even setup the initial LXD server as a cluster and configure it and use lxc cluster enable later on. I’d personally recommend initializing it as a cluster right from the start as that avoids having LXD do the DB reconfig/re-shuffle later on.

So basically it’s best to start with singe lxd cluster member and then it’s totally fine to expand the cluster. Storage, network…etc will be working as well? I mean to expand the storage.

Yeah, you can add/remove storage pools and networks later, that’s fine.

Which will be the best approach to that cluster LXD hosts and LXD containers to be resolved? LXD containers to register to the MAAS DNS (bind9)?

Yeah, you could have MAAS provide a VLAN for the LXD instances, then set it up on all severs, ideally as a bridge, then tell LXD to use that and to delegate to MAAS for IPv4 and IPv6 address allocation (and DNS).

This kinda looks like this:

  • lxc config set maas.api.key SOME-KEY
  • lxc config set maas.api.url http://MAAS-URL:5240/MAAS
  • lxc profile device set default eth0 nictype=bridged parent=br1234 network= maas.subnet.ipv4=MY-SUBNET maas.subnet.ipv6=MY-SUBNET6

In this case, it connects to MAAS (assumes the server’s hostnames all exist in MAAS as machines) and will then use MAAS to register all instances through it. You’ll see your instances show up in a “containers” tab on the machine in MAAS.

Instead of directly going and mess with the main eth0 in the default profile, you’d likely instead want to experiment with this just on a single test instance first :slight_smile:

Does MAAS currently supporting lxd cluster because according to this documentation does not: https://maas.io/docs/snap/3.0/ui/how-to-use-lxd

Depends exactly what part of MAAS you care about.

You can have LXD using MAAS for IPAM (IP Address Management) within a LXD cluster using the steps I showed above, that will work fine so long as all servers in the LXD cluster have a corresponding machine in MAAS with the same name.

What isn’t supported by MAAS currently is MAAS itself creating instances on a LXD cluster, that’s MAAS’ KVM feature. They have work in progress to handle it but it’s not complete yet.

Thank you.