LXD OpenVSwitch and VLANs
LXD is a fantastic container virtualization tool that comes by default with Ubuntu. In one of my applications I needed to have many containers each within it’s own VLAN network.
So I used OpenVSwitch in combination with LXD to achieve this.
There is no inherent facility in LXD to provide VLAN tag numbers to the interface. So it is necessary to use a “Fake bridge”. I managed to do it after reading this article by Scott – VLANs with Open vSwitch Fake Bridges
Let’s say the OpenVSwitch bridge is named vm-bridge and we want to add 10 fake bridges ranging from VLAN 20 to 30. Here’s how I did it:
for i in $(seq 20 30); do
ovs-vsctl add-br vlan$i vm-bridge $i
done
In LXD you can specify the bridge to which it will connect containers to, so I created 10 containers using a similar loop 😀
Further to bind each container to the fake bridge this step is needed:
for i in $(seq 20 30); do
lxc config device set ct$i eth0 parent vlan$i
done
Could you show more of the LXD side of this? For instance how you create the LXD containers so they each get their own assigned VLAN?
thanks
brian
LikeLike
You have to create them like you would create a normal one using lxc launch command then use the lxc config set command I have specified in the post.
LikeLike