Adding LXD VM hosts with the MAAS CLI

Hi all,

To be honest I think it is a bug, I am trying to add an lxd cluster via maas cli, I am issuing command

maas admin vm-hosts create -d type=lxd power_address=lxdbr0_address:8443 password=mysecretpwproject=juju name=lxd3 pool=default

It results in

200 OK

       Connection: keep-alive
   Content-Length: 1013
     Content-Type: application/json; charset=utf-8
             Date: Sun, 06 Nov 2022 18:59:23 GMT
           Server: nginx/1.18.0 (Ubuntu)
           Status: 200
             Vary: Authorization, Cookie
  X-Frame-Options: DENY
  X-Maas-Api-Hash: c5fad5a4a9e2cd2fb3fe98dcdcea34706905f6b8

Success.
Machine-readable output follows:
{
    "tags": [
        "pod-console-logging"
    ],
    "host": {
        "system_id": null,
        "__incomplete__": true
    },
    "zone": {
        "name": "default",
        "description": "",
        "id": 1,
        "resource_uri": "/MAAS/api/2.0/zones/default/"
    },
    "architectures": [],
    "capabilities": [],
    "pool": {
        "name": "default",
        "description": "Default pool",
        "id": 0,
        "resource_uri": "/MAAS/api/2.0/resourcepool/0/"
    },
    "type": "lxd",
    "total": {
        "cores": 0,
        "memory": 0,
        "local_storage": 0
    },
    "memory_over_commit_ratio": 1.0,
    "id": 18,
    "available": {
        "cores": 0,
        "memory": 0,
        "local_storage": 0
    },
    "storage_pools": [],
    "used": {
        "cores": 0,
        "memory": 0,
        "local_storage": 0
    },
    "default_macvlan_mode": null,
    "cpu_over_commit_ratio": 1.0,
    "version": "",
    "name": "lxd3",
    "resource_uri": "/MAAS/api/2.0/vm-hosts/18/"
}

Maas is inside an lxd container in that host, the connectivity is there

ping 10.10.11.13
PING 10.10.11.13 (10.10.11.13) 56(84) bytes of data.
64 bytes from 10.10.11.13: icmp_seq=1 ttl=63 time=0.372 ms
64 bytes from 10.10.11.13: icmp_seq=2 ttl=63 time=0.357 ms
64 bytes from 10.10.11.13: icmp_seq=2 ttl=63 time=0.396 ms (DUP!)
^C
telnet 10.10.11.13 8443
Trying 10.10.11.13...
Connected to 10.10.11.13.
Escape character is '^]'.

Unfortunately every time the outcome is


0 resources :frowning:
I can see the problem being discussed in

But I wonder which conf files the author @minhoryang meant :confused:
In my environment there is a snap installation.
How can one investigate it further?

Hello @hypeitnow

I believe for a snap the location of the conf files will be under /var/snap/maas/current
Can you tell a bit more about your setup? Do you run MAAS behind the load balancer?

Hi @troyanov,

I run Maas behind haproxy but the problem was also present on single node installation

For anyone looking at this in the future the solution for adding single host turned out to be adding maas certificate as lxd trust, if you perform that step as root, the parameter password becomes optional, as far as my testing went, the parameters pool and project are also not mandatory, both are resolved to “default” value.

@billwear maybe it would be worth mentioning in the latest documentation?
Just FYI I performed my testing on maas installed via snap in latest/edge channel.

Hi @troyanov and @billwear ,

The adding of single lxd host was successful but I still cannot add an lxc cluster(I performed exactly the same steps used to add single node - lxc config trust add). The documentation says that I should add any node from the cluster nodes and MAAS will automatically detect cluster. Is there anything else to pay attention to?

Does it matter that the lxd cluster I set up is hosted in ubuntu 22.04 hosts?

Regards

Mateusz

@troyanov and @billwear maybe it would be possible to add some troubleshooting hints for a problem mantioned here? Which logs should contain some valuable piece of information when trying to add kvm host?

Being able to add the lxd cluster would really be a milestone in my current setup.

Thank you