| 1 |
compute-tools: Host Setup (with ifupdown) |
| 2 |
========================================= |
| 3 |
|
| 4 |
|
| 5 |
1. Debian Packages |
| 6 |
------------------- |
| 7 |
|
| 8 |
apt install bridge-utils ifenslave vlan |
| 9 |
|
| 10 |
|
| 11 |
2. Boot Parameters |
| 12 |
------------------ |
| 13 |
|
| 14 |
2.1 CGroup Memory Controller (optional) |
| 15 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 16 |
|
| 17 |
In order to enable the memory controller the following boot parameter needs to be used: |
| 18 |
|
| 19 |
cgroup_enable=memory |
| 20 |
|
| 21 |
|
| 22 |
2.2 CGroup Swap Controller (optional) |
| 23 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 24 |
|
| 25 |
In order to enable the swap controller the following boot parameter needs to be used: |
| 26 |
|
| 27 |
swapaccount=1 |
| 28 |
|
| 29 |
2.3 vsyscall (legacy) |
| 30 |
~~~~~~~~~~~~~~~~~~~~~ |
| 31 |
|
| 32 |
In order to be able to execute binaries linked to older libc versions |
| 33 |
(<= wheezy) on newer linux versions (>= buster), add the following boot |
| 34 |
parameter (see #881813 for more information): |
| 35 |
|
| 36 |
vsyscall=emulate |
| 37 |
|
| 38 |
|
| 39 |
3. Networking |
| 40 |
~~~~~~~~~~~~~ |
| 41 |
|
| 42 |
3.1 Configure Network Bridge |
| 43 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 |
|
| 45 |
3.1.1 Bridge: 1 Interface, standalone, DHCP |
| 46 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 47 |
|
| 48 |
cat > /etc/network/interfaces << EOF |
| 49 |
# /etc/network/interfaces |
| 50 |
|
| 51 |
source /etc/network/interfaces.d/* |
| 52 |
|
| 53 |
auto lo |
| 54 |
iface lo inet loopback |
| 55 |
|
| 56 |
iface eno1 inet manual |
| 57 |
|
| 58 |
auto bridge0 |
| 59 |
iface bridge0 inet dhcp |
| 60 |
bridge_ports eno1 |
| 61 |
bridge_fd 0 |
| 62 |
bridge_maxwait 0 |
| 63 |
bridge_stp 0 |
| 64 |
EOF |
| 65 |
|
| 66 |
|
| 67 |
3.1.2 Bridge: 1 Interface, standalone, static |
| 68 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 69 |
|
| 70 |
cat > /etc/network/interfaces << EOF |
| 71 |
# /etc/network/interfaces |
| 72 |
|
| 73 |
source /etc/network/interfaces.d/* |
| 74 |
|
| 75 |
auto lo |
| 76 |
iface lo inet loopback |
| 77 |
|
| 78 |
iface eno1 inet manual |
| 79 |
|
| 80 |
auto bridge0 |
| 81 |
iface bridge0 inet static |
| 82 |
address 10.0.0.2 |
| 83 |
gateway 10.0.0.1 |
| 84 |
netmask 24 |
| 85 |
|
| 86 |
pre-up ip link set eno1 down |
| 87 |
pre-up ip link set eno1 up |
| 88 |
|
| 89 |
bridge_ports eno1 |
| 90 |
bridge_fd 0 |
| 91 |
bridge_maxwait 0 |
| 92 |
bridge_stp 0 |
| 93 |
EOF |
| 94 |
|
| 95 |
|
| 96 |
3.1.3 Bridge: 2 logical Interfaces, subnet, static |
| 97 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 98 |
|
| 99 |
cat > /etc/network/interfaces << EOF |
| 100 |
# /etc/network/interfaces |
| 101 |
|
| 102 |
source /etc/network/interfaces.d/* |
| 103 |
|
| 104 |
auto lo |
| 105 |
iface lo inet loopback |
| 106 |
|
| 107 |
allow-hotplug eno1 |
| 108 |
iface eno1 inet dhcp |
| 109 |
|
| 110 |
auto bridge0 |
| 111 |
iface bridge0 inet static |
| 112 |
address 10.0.0.1 |
| 113 |
netmask 24 |
| 114 |
|
| 115 |
pre-up ip link add name bridge0 type bridge |
| 116 |
post-down ip link delete bridge0 type bridge |
| 117 |
|
| 118 |
bridge_fd 0 |
| 119 |
bridge_maxwait 0 |
| 120 |
bridge_stp 0 |
| 121 |
EOF |
| 122 |
|
| 123 |
|
| 124 |
3.1.4 Bridge: 3 physical Interfaces, vlan, bonding, static |
| 125 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 126 |
|
| 127 |
cat > /etc/network/interfaces << EOF |
| 128 |
# /etc/network/interfaces |
| 129 |
|
| 130 |
source /etc/network/interfaces.d/* |
| 131 |
|
| 132 |
auto lo |
| 133 |
iface lo inet loopback |
| 134 |
|
| 135 |
allow-hotplug eno1 |
| 136 |
iface eno1 inet dhcp |
| 137 |
|
| 138 |
iface eno2 inet manual |
| 139 |
|
| 140 |
iface eno3 inet manual |
| 141 |
|
| 142 |
auto bond0 |
| 143 |
iface bond0 inet manual |
| 144 |
up ip link set bond0 up |
| 145 |
down ip link set bond0 down |
| 146 |
|
| 147 |
slaves eno2 eno3 |
| 148 |
|
| 149 |
bond-mode 4 |
| 150 |
bond-miimon 100 |
| 151 |
bond-downdelay 200 |
| 152 |
bond-updelay 200 |
| 153 |
bond-lacp-rate 1 |
| 154 |
bond-xmit-hash-policy layer2+3 |
| 155 |
|
| 156 |
iface bond0.100 inet manual |
| 157 |
vlan-raw-device bond0 |
| 158 |
|
| 159 |
auto bridge-100 |
| 160 |
iface bridge-100 inet static |
| 161 |
address 10.100.0.2 |
| 162 |
netmask 24 |
| 163 |
|
| 164 |
bridge_ports bond0.100 |
| 165 |
bridge_fd 0 |
| 166 |
bridge_maxwait 0 |
| 167 |
bridge_stp 0 |
| 168 |
EOF |
| 169 |
|
| 170 |
|
| 171 |
4. Enabling user namespace for unprivileged containers |
| 172 |
------------------------------------------------------ |
| 173 |
|
| 174 |
Linux supports unprivileged containers with the user namespace. |
| 175 |
By default the user namespace is disabled on Debian systems (see #898446). |
| 176 |
To enable user namespace, edit the following file for a permant change: |
| 177 |
|
| 178 |
/etc/sysctl.d/zz-compute-tools.conf |
| 179 |
sysctl -p |
| 180 |
|
| 181 |
or enable it manually with: |
| 182 |
|
| 183 |
echo 1 > /proc/sys/kernel/unprivileged_userns_clone |
| 184 |
|
| 185 |
Note that containers need to be started with the correct |
| 186 |
configuration in /etc/compute-tools/container/config to run unpriviled |
| 187 |
(private-users option). |
| 188 |
|
| 189 |
|
| 190 |
5. Enabling container-shell |
| 191 |
--------------------------- |
| 192 |
|
| 193 |
Managing privileged containers requires root privileges. In order to allow |
| 194 |
unprivileged users to manage privileged containers without granting them |
| 195 |
privileges or accounts, the container-shell can be used together with sudo |
| 196 |
and a container user. |
| 197 |
|
| 198 |
sudo adduser --gecos "compute-tools,,," \ |
| 199 |
--home /var/lib/open-infrastructure/container-shell \ |
| 200 |
--shell /usr/bin/container-shell |
| 201 |
|
| 202 |
|
| 203 |
6. IPv4 and IPv6 dual-stack |
| 204 |
--------------------------- |
| 205 |
|
| 206 |
Examples for /etc/network/interfaces above work for IPv6 too when using correct |
| 207 |
IPv6 addresses and netmasks. |
| 208 |
|
| 209 |
In order to use dual-stack, bridges must have a IPv4 address assigned |
| 210 |
(can be a dummy one from a privacy range or 127.0.0.0/8). |
| 211 |
|
| 212 |
Let me repeat: dual-stack only works when you assign a primary IPv6 address |
| 213 |
(private or public, doesn't matter) *and* add an additional IPv4 address. |
| 214 |
Yes, the IPv4 address can be a private address, the containers can still |
| 215 |
have a public IPv4 address. |
| 216 |
|
| 217 |
A complete example looks like this: |
| 218 |
|
| 219 |
auto bridge0 |
| 220 |
iface bridge0 inet6 static |
| 221 |
address 2a07:6b47:4::4:1 |
| 222 |
netmask 48 |
| 223 |
|
| 224 |
up ip addr add 127.4.4.1 dev $IFACE |
| 225 |
down ip addr del 127.4.4.1 dev $IFACE |
| 226 |
|
| 227 |
bridge_fd 0 |
| 228 |
bridge_maxwait 0 |
| 229 |
bridge_stp 0 |
| 230 |
bridge-mcquerier 1 |