Hi!, I’m begineer using LXD, so I have been trying to provide from external file using shell a file to create a cluster and then join to it from another 2 virtual machines. I’m using vagrant to create 3 virtual machines, and the target is to create load balancer for 2 web sites that are storage inside lxd containers. So the first thing that I did was to provide the configuration for the first lxd cluster in the VM1 as follows:
Above means that I created a Cluster with that ip address, network name and password. After that I need to create new node, and join it to the server1. The problem is I don’t know how to gives the cluster certificate that has been created in the node1.
In the documentation you have linked there is an explicit paragraph about what to put in the preseed file to join a new node, and in particular how to fill the certificate field:
Now create a bootstrap file for another node. You only need to fill in the cluster section with data and config values that are specific to the joining node.
Be sure to include the address and certificate of the target bootstrap node. To create a YAML-compatible entry for the cluster_certificate key you can use a command like sed ':a;N;$!ba;s/\n/\n\n/g' /var/lib/lxd/server.crt , which you have to run on the bootstrap node.
For example:
An easy way to see what you should have passed as preseed is to run lxd init interactively on a second system, answer all the questions and then at the end, answer yes to showing you the preseed file.
My solution was to storage the certificate string inside a variable and after that pull it from my another Virtual Machine as follows
certification=$(</vagrant/servidor.crt)
Is the certificate stored somewhere else? The sed command doesn’t work (using ubuntu 20.10, also in vagrant)
coleman@ubuntu2010:~$ sed ':a;N;$!ba;s/\n/\n\n/g' /var/lib/lxd/server.crt
sed: can't read /var/lib/lxd/server.crt: No such file or directory
My bootstrap node was created with this preseed template (puppet epp syntax, but you should get the idea. It was adapted from the docs page you mentioned).