Containers are a flexible way of sharing a host's resources. Learn how to set up the LXD environment.
- [Narrator] Containers are a popular way of running software in isolated spaces. On Ubuntu, we can use LXD to manage containers on a local host, on a remote host or on a cluster of systems. While LXD comes installed with some versions of Ubuntu, we can install it with apt install LXD if it's not already there. Once it's installed, we'll need to initialize the environment the LXD wI'll run in, including setting where the container images are stored, how the network is configured, whether the host is part of a cluster and whether it's accessible over the network. Depending on your deployment needs, you'll need to make decisions about how to configure this.
But on my system here, I'll configure a one node cluster. To start the process, I'll type LXD init. I'll say yes to clustering and I'll accept this name. I'll press enter to accept this address and then say that no I'm not joining an existing cluster. I'll choose to set a password and then I'll type in that password. Other nodes wI'll need this password to join the cluster. I'll create a new local storage pool and I'll leave the set to directory.
I don't need a remote storage pool right now so I'll say no. And I'm also not connecting to a mass server. I don't have an existing bridge so I'll say no and then I'll accept this default to create a new fan overlay network. That wI'll provide networking services to the containers. I'll say yes I would like my images to be updated automatically and then I prompt it to save a precede file. It's a good idea to save this file. It contains the configuration for this node. It's helpful if you need to add more nodes and it's also just good to have for documentation purposes.
Which of these options are available to you may vary based on your host configuration. Now my configuration has been completed. I'll copy this yaml here with Control + Shift + C. And I'll paste it into a file with Control + Shift + V.
If you're building a cluster, you can continue to setup the subsequent nodes using the credential information that was setup initially. You can either do this manually on each machine or you can use the precede option and then edit the address field and import it into each additional node that you want to be part of your cluster. Each node will need its own network configuration information different from the other nodes. As you know, when a container runs in a clustered setting, it's still running on just one of the hosts. But the LXD clustering doesn't provide fault tolerance underneath a container.
It just provides a system where we can balance resources and manage where things are stored and running ourselves. And keep in mind that clusters need to have the same templates and storage types across all of the nodes.