Community spotlight - we're looking for LXD examples to share

Hi all,

I am working with the LXD team at Canonical, and we’d love to get some input from the LXD community in sharing examples and stories that could help new users understand LXD better.

We are looking for practical examples that could be of use for others - whether it’s a production setup hosting business-running applications or an interesting home lab, we’re interested in hearing more. If you are using LXD for development in a specific area (for example data science) and have some tips and tricks to share for others, that would be interesting too.

If you are willing to share your story to a wider audience we can do that in several ways:

  1. You can always do it yourself by making a detailed post in this forum

  2. We could write an article and share it on the Ubuntu blog (example), or our Ubuntu webpage. This can be anonymised if needed.

  3. We could record/stream a demo or a Q&A on our youtube channel

  4. Any combination of the options above

Please comment or reach out with any suggestions, and I’m here to assist.

3 Likes

Thanks @mionaalex!

I’m quite excited about this, especially for the potential to have others share their LXD experience on our YouTube channel. It’s been a LOT of me talking on there so far, so some diversity would be nice :wink:

And we’re really looking for just about anything interesting, doesn’t have to be production grade, weekend projects are really fun too! Just looking for people who want to share something fun they did in the hope of inspiring others.

3 Likes

Our company https://dwellir.com is exploring LXD heavily at the moment to see if it would fit our future cloud setups.

So far, our experience has been great and we could absolutely share some of our experiences. I’m not sure exactly how, but we are absolutely willing to work with the community to provide some insight to how lxd has helped us so far.

2 Likes

@erik_lonroth Thank you Erik, that would be great. We can have a chat about how best to do it, I’ll reach out

1 Like

@mionaalex I’m living not far from Stockholm - we should meet up?

we are using an LXD container to run an ERP-application (erpnxext) for our company, which has served us well thus far even in critical situation (running out of storage on the storage pool).

I wrote a short blogpost about this here and I’d be happy to showcase this (not sure whether it is sophisticated enough though :slight_smile: )

Would be happy to discuss LxdMosaic, probably the most “interesting” thing lately would be the search here.

2 Likes

Sure, why not. Sent you a message.

Thanks, Gunnar. We’re not necessarily looking for super-sophisticated stuff. Yours is a practical example that can be useful for others in a similar situation, so exactly what we’re looking for. I’ll message you so we can set a time for a chat about it.

I use LXD system containers extensively in my home lab (https://radar231.com/Homelab.html). I use them as development and testing systems, as well as docker and kubernetes servers.

I’ve got a few LXD specific posts on my blog (mainly as aide-memoires for myself :-)); https://radar231.com/LXD.html.


Rick

(originally posted at https://radar231.com/Use Cases for LXD.html)


References

Introduction

In response to the request for LXD usage examples posted to the Linux Containers forum, I’ve decided to describe a couple of my personal uses of LXD.

First, a bit of background information. I’ve recently retired from a 41 year career in the Canadian Public Service, where I worked in a variety of Electronics Engineering and Information Technology positions. My last position was working as a systems analyst, designing and implementing systems integration solutions. My last project was to develop a system to act as a communications bridge between two very different legacy systems.

Since retirement I’ve filled my time by setting up what I consider a fairly modest but quite effective home lab environment. A post describing my home lab can be found in the references section of this post.

Both of these examples leverage LXD extensively.

Communications Bridge

While the production deployment of the final system didn’t utilize LXD, the design and development of the solution was performed exclusively on LXD containers. I had been using LXD containers for many years, both as development systems as well as for testing code and configurations on a variety of Linux distributions. In this particular case, the final system was going to end up a multi-channel meshed system consisting of many physical servers. Each channel consisted of a number of servers and firewalls, each performing a function of protocol translation, data routing or security isolation. The channels were configured in a mesh interconnection, providing redundancy and fault tolerance, with the capability to detect node failures and modify the routing to bypass the failures.

As can be seen from my description, this was going to be a fairly complex system, and was going to be a challenge to develop as well as to perform initial and ongoing systems testing. LXD containers provided a perfect development platform for this. I had a custom deployment script that would spin up more than 15 containers from a custom local image, set up the isolated networks that provided the interconnection at various levels within the system, deployed the applicable code to each node and then finally reboot all the containers to bring the development system up into operations.

Once done with a development session, another script would shut down all the containers, tear down the virtual networks and remove all of the containers. Deployment of the development environment would only take a few minutes to accomplish, and the clean up and removal of the environment was complete within another minute or so.

While a similar environment could have been created using something like terraform to manage virtual machines, it would have been many orders of magnitude slower to deploy than a set of LXD containers, and would have ended up using a much larger amount of system resources. In fact, the whole LXD development environment was actually deployed within a VM running LXD (albeit, a rather beefy VM :-)).

Home Labs and LXD

After having used LXD for so many years at work, it only made sense to go all in with LXD for my home lab. While I have a number of virtualization servers in my home lab, all production workloads are containerized, and run either on my kubernetes cluster, or on docker encapsulated within an LXD container. I do have KVM/QEMU via libvirt running, but this is mainly only used for desktop VM’s that require sound. This is due to the lack of virtio sound card emulation making sound an issue for LXD VM’s. I do try to use LXD VM’s for any server or test environment that doesn’t require sound though.

As can be seen from the following screen capture, I have a number of LXD containers running. Some are acting as X86 nodes for my kubernetes cluster. There are currently two that are running as docker aggregation servers, where I run containerized applications that won’t run correctly on the k8s cluster. I have a development system where I do my coding as well as ansible based management of the home lab servers. I also have one running Nginx Proxy Manager which manages internal access to applications running in either the kubernetes cluster or in docker containers within the home lab.

![LXD and Libvirt](upload://kVt2jCKkA95Z0E2Ix0A2hZHRbst.png "LXD and Libvirt")

Conclusion

These two examples are fairly small in scope, and barely scratch the surface of what LXD is capable of. They do illustrate both development/testing as well as production usage of LXD though. Moving forward I see no reason to stop using LXD for both containers and VM’s. I have a few LXD related postings on my blog now, and there will probably be more posts added as I move forward with LXD.

3 Likes

My company https://greymatter.io uses LXD for running our CI/CD pipelines.

Architecture, Motivation

An LXD server (usually one big AWS instance) running ~9 LXD containers of different types. The LXD containers are built with Packer from a single file, which helps us keep them as consistent as possible, and only introduce differences where it’s necessary. For instance, we have Alma linux and two versions of Ubuntu to produce different builds for our customers, and to test our builds on different systems.

The agents are Buildkite. We migrated to Buildkite from CircleCI to get 1) major build speedups and 2) enforce a shared environment across our projects. The speedups come from pre-baking all the tools and packages we need into the containers, and from the better-performing server that we provision. We don’t put any CPU or memory constraints on our LXD containers. We just let the underlying Linux scheduler do its thing.

One of the artifacts we produce from these Buildkite agents are OCI containers. We use the buildah tool, and podman. These tools leave behind lots of layers that can fill up the disk, but since each environment is an LXD container, we can delete the agent’s container and the disk space problem is remediated. We want to introduce automation to “roll” these containers regularly automatically, but we haven’t yet.

Other Uses

We do run some internal tools and testing environments on other LXD servers, but CI/CD is our most serious use case, for now.

2 Likes

I’ve used LXD for two solutions:- The first is a distributed data centre where the heat from a complete node is transferred to the domestic water heater than its installed in.

The customer created tasks are LXD container instances and are created on a sandbox machine and then when they are ready are distributed by a Python pylxd task management script which has the appliances polling a control server.

2 Likes

The second is for a company called AtCore which has a specialised in memory database used for travel industry lookups. The legacy application is vertical scaled and servers generally have a couple of TB of RAM.

I’ve using LXD to shard the data into smaller chunks using LXD and then have a frontend server application to join the results together into a single response.

And this is all managed with python pylxd scripts.

3 Likes

This sounds interesting to me, got a blog post or anything?

As part of another project I created a GitHub project which allows an ssh connecting to pass from the host into a LXD instance directly via lxc exec and is directed by the SSH public key. Very useful for giving users direct access to a LXD instance on a single IP/hostname gateway host.

4 Likes

Using LXD in Home Labs

I have a Mini PC.
I am running self-hosted software on this PC using Docker.
And code-server (running on Docker).

Before using LXD, I need to use code-server very carefully.
Because the Docker container cannot obtain a dedicated IP from the home network. (Port conflict)
LXD can create independent computing units with dedicated IP. That was great!

4 Likes

Hello @Tyuuhou.Den, do you have more information on that? Sounds cool :slight_smile: