-
Notifications
You must be signed in to change notification settings - Fork 37
Setup LXD based on a feature pull request
This guide details the steps for setting up a LXD build based on a pull request that is not yet released.
-
Make sure you have lxd snap installed, if not, refer to HACKING.md for instructions.
-
Create and launch a VM instance with
ubuntu:22.04
, name itlxd-dev
or something suitable. The VM will be used as a development environment for lxd where the project binaries are compiled. Doing it this way ensures that dependencies are the same as those used in the published snaps. -
Once the VM is running, navigate to its terminal:
- update and upgrade apt with:
apt update apt -y upgrade
- install package dependencies for lxd
apt -y install acl attr autoconf automake dnsmasq-base git libacl1-dev libcap-dev liblxc1 liblxc-dev libsqlite3-dev libtool libudev-dev liblz4-dev libuv1-dev make pkg-config rsync squashfs-tools tar tcl xz-utils ebtables apt -y install lvm2 thin-provisioning-tools apt -y install btrfs-progs apt -y install curl gettext jq sqlite3 socat bind9-dnsutils apt -y install shellcheck
- install go
apt -y install snapd snap install go --classic
- clone the source code
git clone https://github.com/canonical/lxd cd lxd
- check out a specific pull request from the lxd repo. You will need the pull request id and replace
pull_id
in the command below
git fetch origin pull/[pull_id]/head:[branch_name] && git switch [branch_name]
- build lxd dependencies, make sure you are inside the
/lxd
directory
make deps
- at the end of step 3.6, there will be some instructions displayed in the shell output for setting up environment variables. Copy those and run them to set them up, an example is shown below (to persist the environment variables you should and them to
.bashrc
inside of the VM):
export CGO_CFLAGS="-I/root/go/deps/raft/include/ -I/root/go/deps/dqlite/include/" export CGO_LDFLAGS="-L/root/go/deps/raft/.libs -L/root/go/deps/dqlite/.libs/" export LD_LIBRARY_PATH="/root/go/deps/raft/.libs/:/root/go/deps/dqlite/.libs/" export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
- We can now build the lxd and lxc binaries
make
- Once the binaries have been compiled, add the below line items to
.bashrc
. Then runsource ~/.bashrc
.
export GOPATH="$(go env GOPATH)" alias lxc="$GOPATH/bin/lxc" alias lxd="$GOPATH/bin/lxd -v -d"
-
Finally now you can run the command
lxd
in the terminal and the lxd server will start running. -
In case if there are upstream changes from the lxd pull request, you can updated the local git branch that's tracking the pull request and execute steps v. - x. again.
-
Connect the UI to the lxd server running inside of the VM instance. To do this, note down the IP address for the VM instance and add it to
.env.local
in your lxd-ui project. The IP address should be set against theLXD_UI_BACKEND_IP
environment variable as shown below in the example.
LXD_UI_BACKEND_IP=10.147.196.7
- Run
dotrun
from the root level of yourlxd-ui
project and now the UI will be conected to the lxd server that contains features that do not exist in the official snap release.