Alpine Linux LXD Setup

TODO

Install LXD

Configure Bridge Interface

$ sudo apk add bridge
$ cat <<END | sudo tee /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0

auto br0
iface br0 inet static
    bridge-ports eth0
    bridge-stp 0
    address <ip>
    netmask <mask>
    gateway <gw ip>
END

## NOTE: How to properly create this without rebooting?
$ sudo reboot

Install btrfs Filesystem

$ echo btrfs | sudo tee -a /etc/modules
$ sudo apk add btrfs-progs
$ sudo lbu commit -d
$ sudo reboot

Install LXD

$ sed -i 's/edge/^#//' /etc/apk/repositories
$ apk update
$ apk upgrade
$ apk add lxd
$ rc-update add lxd
$ service lxd start
$ lbu commit -d

Configure LXD

## Wipe storage pool partition
$ sudo dd if=/dev/zero of=/dev/sda3 count=1024

$ sudo lxd init # Look into non-loop backing stores (RAID, non-RAID)
Would you like to use an existing empty block device: yes
Path to the existing block device: /dev/sda3
Would you like to create a new local network bridge? No
Would you like to configure LXD to use an existing bridge or host interface? Yes
Name of the existing bridge or host interface: br0
Would you like LXD to be available over the network? Yes
Trust password for new clients: <password>

$ sudo chgrp lxd /var/lib/lxd/unix.socket
$ sudo adduser <username> lxd
$ logout
## Login again to add lxd group

$ sudo lxc config set core.https_address [::]:<port> # 8443 is default
$ sudo lxc config set core.trust_password <password> # How to do this with certs?
$ sudo lxc profile set default boot.autostart true
## On 'remote' box:
$ lxc remote add <name> <ip>:<port>