Proxmox nodes: install in an LXC container instead of Docker on the node
Run on a Proxmox VE node (pct and /etc/pve present), the installers now default to INSTALL_MODE=lxc: create or reuse (by tag netmon-hub / netmon-probe) an unprivileged Debian LXC on vmbr0 with nesting and onboot, push the installer into it (rebuilt from its own functions) and run it there in native mode. LXC_* variables override ID, storage, template storage, bridge, IP and size. Docker on a node now needs an explicit INSTALL_MODE=docker and prints a warning; an earlier Docker install is pointed out with removal steps. Ping setup inside an unprivileged container stays within the mapped group range, which the kernel requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
edeb77f833
commit
a17f2b502c
7 changed files with 382 additions and 38 deletions
65
README.md
65
README.md
|
|
@ -38,20 +38,21 @@ It has two parts, built from this one repo and one Docker image:
|
|||
|
||||
## Install
|
||||
|
||||
Both installers are one pasted line. They work on Linux and macOS. Settings can be passed as environment variables; the top of `install.sh` lists them. There are two ways to run:
|
||||
Both installers are one pasted line. They work on Linux and macOS. Settings can be passed as environment variables; the top of `install.sh` lists them. Where it installs depends on the machine (`INSTALL_MODE`):
|
||||
|
||||
| Mode | What it is | Default on |
|
||||
|---|---|---|
|
||||
| `docker` | The app in a container (compose), Docker installed if missing | Linux hosts (VMs, bare metal) |
|
||||
| `lxc` | Creates a small Debian LXC container (or reuses the one it made before) and installs natively inside it. The node itself gets no Docker and no packages. | Proxmox VE nodes |
|
||||
| `native` | A Python virtualenv plus a boot service: systemd on Linux, launchd on macOS | macOS, and inside LXC containers |
|
||||
| `docker` | The app in a container (compose), Docker installed if missing | other Linux hosts (VMs, bare metal) |
|
||||
|
||||
Pass `INSTALL_MODE=docker` or `INSTALL_MODE=native` to choose. The mode is saved in `.env`, so re-runs keep it. Native mode needs Python 3.11+ (Debian 12, Ubuntu 24.04 or newer; the installer installs it with apt or Homebrew). On Linux it runs as root and creates a `netmon` system user for the service.
|
||||
Pass `INSTALL_MODE=...` to choose another mode. Outside Proxmox, the mode is saved in `.env`, so re-runs keep it. Native mode needs Python 3.11+ (Debian 12, Ubuntu 24.04 or newer; the installer installs it with apt or Homebrew). On Linux it runs as root and creates a `netmon` system user for the service.
|
||||
|
||||
Either way, the service starts on boot and restarts if it crashes.
|
||||
|
||||
### Which machine gets what
|
||||
|
||||
- **Proxmox VE nodes:** don't install Docker on the node itself. Docker changes the host firewall, and with the Proxmox firewall on that can cut traffic to guests. Run the hub and the probes in small LXC containers instead (below).
|
||||
- **Proxmox VE nodes:** run the installer on the node as root. It creates an LXC container for the hub or probe and installs inside it. Don't use Docker on the node itself: Docker changes the host firewall, and with the Proxmox firewall on that can cut traffic to guests.
|
||||
- **Mac mini:** native mode. Docker Desktop runs containers in a Linux VM, so a probe there would measure the VM, and it only starts at login. The installer refuses Docker on macOS.
|
||||
- **Other Linux machines or VMs:** Docker mode (the default), or `INSTALL_MODE=native` if you prefer no Docker.
|
||||
|
||||
|
|
@ -95,26 +96,52 @@ The probe's test server listens on port 8765 (`PROBE_PORT`) on all interfaces.
|
|||
|
||||
**Docker probes** use host networking, so they measure the machine's real link and see its ARP table.
|
||||
|
||||
### Proxmox: hub and probes in LXC containers
|
||||
### Proxmox: what the installer does on a node
|
||||
|
||||
Create one small unprivileged Debian 12 container per node for the probe, and one anywhere for the hub. Put each on the node's LAN bridge, so its traffic leaves through the node's NIC and measures that node's link. For example, on node `pve1`:
|
||||
Run the same commands as above on the node, as root. The installer:
|
||||
|
||||
1. **Finds or creates a container**, tagged `netmon-hub` or `netmon-probe`. Re-running finds it again, so it never makes a second one. A new container is:
|
||||
- unprivileged Debian 12 or 13, from the newest template in `local`, downloaded if missing
|
||||
- 1 core, 512 MB, 4 GB on `local-lvm` (or `local-zfs`, or the first storage that holds containers)
|
||||
- `nesting=1`, start on boot
|
||||
- on `vmbr0` with DHCP
|
||||
- named `netmon-hub` or `netmon-probe-<node>`
|
||||
2. **Starts it** and waits for network.
|
||||
3. **Copies the installer in** and runs it in native mode. It installs Python, sets up ping and creates the systemd service.
|
||||
4. **Prints the container's IP** and the `pct exec` commands to update it, read its logs and edit its settings.
|
||||
|
||||
To change the defaults, set these before `bash`:
|
||||
|
||||
| Variable | Default |
|
||||
|---|---|
|
||||
| `LXC_ID` | the next free ID |
|
||||
| `LXC_STORAGE` | `local-lvm`, else `local-zfs`, else the first container storage |
|
||||
| `LXC_TEMPLATE_STORAGE` | `local` |
|
||||
| `LXC_BRIDGE` | `vmbr0` |
|
||||
| `LXC_IP` | `dhcp`; a static address looks like `192.168.68.50/24` together with `LXC_GW=192.168.68.1` |
|
||||
| `LXC_CORES`, `LXC_MEMORY`, `LXC_DISK` | `1`, `512`, `4` (GB) |
|
||||
|
||||
For example: `curl -fsSL .../install.sh | LXC_IP=192.168.68.50/24 LXC_GW=192.168.68.1 bash`.
|
||||
|
||||
Notes:
|
||||
- **Fixed IP for the hub:** give its container a DHCP reservation or a static IP. Probes report to it, and the Add probe command contains its address.
|
||||
- **What the probe measures:** the container sits on the node's bridge, so its traffic leaves through the node's NIC, and the probe measures that node's link.
|
||||
- **Neighbors:** a probe in a container sees only the devices it has talked to, not everything the node sees. AdGuard is the main source of the client list, so this rarely matters.
|
||||
- **Ping:** inside an unprivileged container, the ping setting is limited to the container's mapped groups (0–65535). The installer handles that.
|
||||
|
||||
#### Removing a Docker install from a Proxmox node
|
||||
|
||||
An earlier version of the installer used Docker when run directly on a node. To undo that, as root on the node:
|
||||
|
||||
```bash
|
||||
pveam update && pveam available --section system | grep debian-12 # find the template name
|
||||
pveam download local debian-12-standard_12.12-1_amd64.tar.zst # use the name from above
|
||||
pct create 210 local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst \
|
||||
--hostname probe-pve1 --cores 1 --memory 512 --swap 256 --rootfs local-lvm:4 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp --unprivileged 1 --features nesting=1 --onboot 1
|
||||
pct start 210 && pct enter 210
|
||||
apt update && apt install -y curl # if the template lacks curl
|
||||
curl -fsSL http://<hub-ip>:8000/install-probe.sh | HUB_URL=http://<hub-ip>:8000 PROBE_TOKEN=... bash
|
||||
cd /opt/network-monitor && docker compose down -v --rmi all; cd / && rm -rf /opt/network-monitor # same for network-probe
|
||||
apt-get purge -y $(dpkg-query -W -f='${binary:Package}\n' 'docker-*' containerd.io 2>/dev/null)
|
||||
rm -rf /var/lib/docker /var/lib/containerd /etc/apt/sources.list.d/docker.* /etc/apt/keyrings/docker.*
|
||||
```
|
||||
|
||||
- **`nesting=1`:** Debian 12's systemd needs it in an unprivileged container. New containers get it by default on recent Proxmox.
|
||||
- **Detection:** the installer sees it is in an LXC and uses native mode; no Docker inside.
|
||||
- **Docker instead:** if you'd rather run Docker inside the LXC, add `keyctl=1` to the features and pass `INSTALL_MODE=docker`.
|
||||
- **Neighbors:** a probe in an LXC sees only the devices that container has talked to, not everything the node sees. AdGuard is the main source of the client list, so this rarely matters.
|
||||
- **Reserved addresses:** give the containers DHCP reservations or static IPs, so the matrix stays readable and peers keep finding each other.
|
||||
Docker also changes the firewall: its rules and a `DROP` policy on the `FORWARD` chain stay until the next reboot.
|
||||
- **Check:** `iptables -S FORWARD | head -1`.
|
||||
- **Fix:** if it says `-P FORWARD DROP` and guests have trouble talking to each other or the internet, run `iptables -P FORWARD ACCEPT`, or reboot the node when convenient.
|
||||
|
||||
### Mac mini
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue