meeting LXC on Ubuntu Core

ingredients :

  • NUC
  • Ubuntu Core distro
  • 2 usb Keys
  • Soundtrack :

The real topic of this post should be “how a rash buy has becomes an exciting surprise”.
I was quite annoyed making new virtual machines on my laptop and I needed an environment in order to test some Ansible scripts I made.

Searching a solution I find out, on the second hand market, a bare bone solution from Intel : NUC Kit NUC8i5BEH. Small less my 2007 old but glorious Mac Mini and cheap enough…

begin :

I need a small cube in a corner of the house, no screen, neither keyboard but only an ethernet plug. A device where run dockers, replicate environments….
My idea was to use the NUC as base for a Virtual Box’s host but this plan would been changed soon. I’ve followed the instructions in Ubuntu Core on NUC instead the Ubuntu Desktop on NUC. The process is quite basic then no problem and, at the end of installation, I pushed my public ssl key on the Canonical’s cloud and my NUC is immediatly accessible to me by ssh. I’ve never faced Ubuntu Core before and the impact was quite odd. At first time Ubuntu Core seems cheap and basic. I’ve spent some time to understand the philosopy of Snap tool as package manager, I’m used to apt on Ubuntu. After some investigation was clear that Linux Container LXC/LXD are the natural choise for virtualization on Ubuntu Core. Following this approach I can avoid the creation of a a cluster of virtual machines based on Virtual Box. Lxc allows to create a flock of containers at operating system-level (Linux) more economic than virtual machines.

With LXD I’d create the host and then many containers on it. By default, all containers run in a private network on the host. My needing is to access the containers in the same way as in case of phisical servers and control them whit ssh term. On this containers I’d deploy applications by Dockers which run on a LXD host . Another requirement is to realize some kind of virtual networking in order to control the LXD host and the Linux containers by ssh and access to all the Docker services.

Here the map of the plan…

I’d like to be able to create and destroy networks and containers, deploy applications using terraform, ansible and openstack.

Once the Ubuntu Core has been installed and my ssl key has been uploaded on Ubuntu SSO…..
the first ssh connection and network manager installation by snap

what I need? A network bridge in order to have a network interface for each LXC container. For this I have to disable the eth0 and for this reason I have to enable the wireless interface in order to switch to this ip my ssh console.

Now let’s create the bridge interface and switch off the eth0 enstabilish the ssh connection to the wireless ipon wlan0. This step is needed because I’ve activated only the wired interface at installation time.

The host is ready for LXD and the containers but before, the bridge has to be assigned to as network interface for LXC

pay attention to the bridge profile editing…

cat <<EOF |sudo  lxc profile edit bridgeprofile
description: Bridged networking LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
EOF

next, configure ssh access on the container and clone it

ssh console by ssl key

clone the container

access by ssh to the cloned containers