-
Notifications
You must be signed in to change notification settings - Fork 37
Setup local LXD cluster
David Edler edited this page May 17, 2023
·
3 revisions
- Create a new project with all settings to default. Choose a good name like "my-cluster".
- Edit the default profile in the "my-cluster" project and
- Choose an existing storage pool.
- Add a network "lxcbr0" with name "eth0".
- Create and start 3 instances with "jammy" and all default settings
- All 3 instances should have a shared network and get an ipv4 like "10.216.192.xxx" after booting.
- Open the terminal tab of the first instance
- Run "lxd init"
- Answer 1st question with yes: "Would you like to use LXD clustering? (yes/no) [default=no]: yes"
- Accept default for the next 3 questions
- Setup password auth: "Setup password authentication on the cluster? (yes/no) [default=no]: yes"
- Choose a password and confirm it: "Trust password for new clients: "
- Accept default for the remaining questions
- Open a terminal tab on the 2nd instance
- Run "lxd init"
- Answer 1st question with yes: "Would you like to use LXD clustering? (yes/no) [default=no]: yes"
- Accept default for the next question
- Answer joining a cluster with yes "Are you joining an existing cluster? (yes/no) [default=no]: yes"
- Accept default for the next two questions
- Enter ip of the first instance "IP address or FQDN of an existing cluster member (may include port): 10.216.192.xxx"
- Confirm the fingerprint, "Is this the correct fingerprint? (yes/no/[fingerprint]) [default=no]: yes"
- Enter trust password from the step 4.5. "Cluster trust password: "
- Allow data override "All existing data is lost when joining a cluster, continue? (yes/no) [default=no] yes"
- Accept default for the last two questions
- Repeat the steps from 5. for the 3rd instance to add it to the cluster
- Ensure your cluster is running on one of the three nodes
- in the terminal, run "lxd cluster show" and verify all three nodes are listed.
- Add your certificate to the new cluster
- In your local checkout of lxd-ui, run dotrun once, to ensure your certificates are created.
- Copy the contents of
keys/lxd-ui.crt
from your checkout directory - Open a terminal to one of the three cluster nodes
- Create a new file "vim cert" and paste the contents from step 8.2., save and exit the file
- Add that cert to the trust store "lxc config trust add cert"
- Ensure everything is setup correctly "lxc config trust list" should look like this:
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
| TYPE | NAME | COMMON NAME | FINGERPRINT | ISSUE DATE | EXPIRY DATE |
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
| client | cert | localhost | 438fe5856e9a | Jan 26, 2023 at 8:36am (UTC) | Apr 14, 2031 at 8:36am (UTC) |
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
| server | enabling-hermit | root@enabling-hermit | e2be195e8a3d | May 15, 2023 at 7:34am (UTC) | May 12, 2033 at 7:34am (UTC) |
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
| server | polished-mustang | root@polished-mustang | 32c6836027af | May 15, 2023 at 7:38am (UTC) | May 12, 2033 at 7:38am (UTC) |
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
| server | suited-octopus | root@suited-octopus | c980c04ce1f8 | May 15, 2023 at 7:43am (UTC) | May 12, 2033 at 7:43am (UTC) |
+--------+------------------+-----------------------+--------------+------------------------------+------------------------------+
- Update the ip for your local dev setup to use the cluster as a backend
- Create a file
.env.local
in the main directory of your lxd-ui checkout - Enter a single line with the content
LXD_UI_BACKEND_IP=10.216.192.148
, replace the ip with one of the cluster members. (Warning, the ip might change after rebooting the cluster nodes). - (Re-) start dotrun
- You can see and manage the cluster now under https://localhost:8407/ui/cluster
- Create a file