Skip to main content

Canonical LXD

The LXD integration reads an LXD server, or a whole LXD cluster through any one member, through the LXD REST API. It runs on an Integrator inside your network.

It is read-only. The integration never starts, stops, snapshots or reconfigures anything.

What it collects​

SyncCollects
Hypervisor discoveryThe cluster and every member with its LXD version, OS, kernel, CPU, memory, state, roles and failure domain
Instance discoveryVirtual machines and system containers in every project with their OS, addresses, MACs, CPU, memory, state and member; the image store
Network discoveryManaged bridges and networks with their IPv4 and IPv6 subnets and gateways

LXD runs both containers and virtual machines. Each is reported by its type: system containers appear under Compute > Containers and virtual machines under Compute > Instances, next to those from every other cloud. Images appear under Compute > Registries.

Create a read-only client certificate​

LXD authenticates API clients by TLS client certificate.

  1. Generate a certificate and key for the integration:

    openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 -sha384 -days 3650 -nodes \
    -keyout inventory.key -out inventory.crt -subj "/CN=inventory"
  2. On LXD 6 or later, create a group that can only view, and add the certificate to it:

    lxc auth group create inventory-readers
    lxc auth group permission add inventory-readers server viewer
    lxc auth identity create tls/inventory inventory.crt --group inventory-readers

On LXD 5.21 LTS, certificates cannot be limited to viewing. lxc config trust add inventory.crt works, but the certificate then has full access to the server. Prefer LXD 6, or keep the key on the Integrator only.

In a cluster, run these on any member: the trust store is shared.

Connect it​

  1. Under Integrations, add Canonical LXD with the server's hostname (any cluster member), the certificate (inventory.crt) and its private key (inventory.key).
  2. In the integration's settings, assign the Integrator that can reach the server on port 8443.
  3. Enable the syncs you want.

LXD serves its own self-signed certificate. The first connection records the certificate's fingerprint and later connections must present the same certificate. After replacing it, clear the pinned fingerprint in the integration's settings.

A certificate the server does not trust fails the sync with an error. It does not report an empty server.