-
Notifications
You must be signed in to change notification settings - Fork 0
Demonstration 2
Demonstration 2 builds on the single step test sequence from the previous demo:
-
We'll run the test on two LXC containers instead of the local host. To do so, we'll introduce
etce-lxcand the ETCE LXC Plan File for creating networks of LXC containers and Linux bridges. -
Many Wrappers expose configuration parameters that can be conveniently set at run time. We'll use
etce-wrapperto look at theutils.helloparameters and show how to set their values insteps.xmlor with a separate ETCE Configuration File.
ETCE executes applications on test hosts over SSH. No matter whether the hosts are real, virtual, local or remote, if ETCE can connect to the target user account via public key authentication, it can use the host in tests.
While ETCE was initially developed on a rack of physical servers, the more recent evolution of multi-CPU systems means that ETCE can orchestrate relatively complex EMANE emulations of several dozen nodes, even on a single machine. Obviously virtualization is the key to this, and light-weight LXC containers are a favorite option.
etce-lxc eases the task of setting up LXC networks. Given a self-contained
LXC Plan File, etce-lxc:
* Generates LXC version appropriate lxc.container.conf style
configuration files from templates for multiple containers,
optionally situated on multiple physical hosts.
* Generates an init script run by the containers on startup.
For ETCE, this invariably means starting an `sshd` instance.
* Creates operating directories for each container in the
ETCE Working Directory (under `lxcroot`).
* Runs `lxc-execute` to start the containers and creates
the Linux Bridges to interconnect them. Bridges are
named in the Plan File, explicity or implicitly
* Optionally populates /etc/hosts with Plan File marked interface
addresses and host names.
Demonstration 2 is contained in the 02.hello_lxc subdirectory. The
LXC Plan File for the demo is 02.hello_lxc/doc/lxcplan.xml:
<lxcplan>
<hosts>
<host hostname="localhost">
<bridges>
<bridge name="br.ctl" persistent="false">
<ipaddress>
<ipv4>10.76.0.200/24</ipv4>
</ipaddress>
</bridge>
</bridges>
<containers>
<container lxc_name="node-${'%03d' % lxc_index}" lxc_indices="1-2">
<parameters>
<parameter name="lxc.console" value="none"/>
<parameter name="lxc.tty" value="1"/>
<parameter name="lxc.pts" value="128"/>
</parameters>
<interfaces>
<interface bridge="br.ctl">
<parameter name="lxc.network.type" value="veth"/>
<parameter name="lxc.network.name" value="backchan0"/>
<parameter name="lxc.network.flags" value="up"/>
<parameter name="lxc.network.hwaddr" value="02:00:${'%02x' % lxc_index}:01:00:${'%02x' % lxc_index}"/>
<parameter name="lxc.network.ipv4" value="10.76.0.${lxc_index}/16"/>
<parameter name="lxc.network.veth.pair" value="veth.ctl.${lxc_index}"/>
</interface>
</interfaces>
<initscript>#!/bin/bash
# make node for tun device
mkdir /dev/net
mknod /dev/net/tun c 10 200
pidfile="${lxc_directory}/var/run/sshd.pid"
/usr/sbin/sshd -o "PidFile=$pidfile" -o "PermitRootLogin=yes" -o "PasswordAuthentication=no"
</initscript>
</container>
</containers>
</host>
</hosts>
</lxcplan>The hosts element contains one or more host children. Each host
corresponds to an available compute resource, typically a physical
server, that will run the bridges and containers defined underneath.
The bridges section explicitly names Linux Bridges that will be created on the host, along with an optional IP Address.
[etceuser@host]$ ls /tmp/etce/lxcroot
etce.lxc.lock node-001 node-002
[etceuser@host]$ tree /tmp/etce/lxcroot/node-001
/tmp/etce/lxcroot/node-001
|__ config
|__ init.sh
|__ log
|__ mnt
|__ var
|__ lib
|__ log
|__ run
|__ sshd.pid
[etceuser@host]$ cat /tmp/etce/lxcroot/node-001/config
lxc.utsname=node-001
lxc.console=none
lxc.tty=1
lxc.pts=128
# br.ctl interface
lxc.network.type=veth
lxc.network.flags=up
lxc.network.hwaddr=02:00:01:01:00:01
lxc.network.ipv4=10.76.0.1/16
lxc.network.name=backchan0
lxc.network.veth.pair=veth.ctl.1
lxc.network.link=br.ctl
# loopback interface
lxc.network.type=empty
lxc.network.flags=up
[etceuser@host]$ cat /tmp/etce/lxcroot/node-001/init.sh
#!/bin/bash
# make node for tun device
mkdir /dev/net
mknod /dev/net/tun c 10 200
pidfile="/tmp/etce/lxcroot/node-001/var/run/sshd.pid"
/usr/sbin/sshd -o "PidFile=$pidfile" -o "PermitRootLogin=yes" -o "PasswordAuthentication=no"
Copyright (c) 2019 - Adjacent Link LLC, Bridgewater, New Jersey
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 4.0 International License.