From 56dcf32f8cb248dda1ba302199f2a314a3f7ff1a Mon Sep 17 00:00:00 2001 From: shira Date: Sun, 11 Oct 2026 02:31:14 +0300 Subject: [PATCH] feat(deploy): prepare the LXD host for the isolated runner and labs --- deploy/labs/acls.sh | 34 ++++++++++++++++++ deploy/labs/lxd-preseed.yaml | 68 ++++++++++++++++++++++++++++++++++++ docs/en/DEPLOY.md | 25 +++++++++++++ docs/ru/DEPLOY.md | 25 +++++++++++++ 4 files changed, 152 insertions(+) create mode 100755 deploy/labs/acls.sh create mode 100644 deploy/labs/lxd-preseed.yaml diff --git a/deploy/labs/acls.sh b/deploy/labs/acls.sh new file mode 100755 index 0000000..bbf5527 --- /dev/null +++ b/deploy/labs/acls.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Creates the network ACLs referenced by lxd-preseed.yaml (TASK-592). +# Run before the preseed. Rules are stateful: replies to allowed traffic pass. +set -euo pipefail + +# The ACL filters forwarded traffic before Docker masquerades it, so the +# backend is matched by the app subnet; host-side tools come from the bridge +# address. The token on the control API, not the source address, authorizes +# callers: other containers of the app network reach the port but not the API. +app_subnet="${APP_SUBNET:-172.29.79.0/24}" +runner_host_side="${RUNNER_HOST_SIDE:-10.80.0.1/32}" +runner_port="${RUNNER_PORT:-8443}" + +ensure_acl() { + lxc network acl show "$1" >/dev/null 2>&1 || lxc network acl create "$1" /dev/null || true +done + +# Lab management: the checker and the console gateway live on the host side +# and connect to the nodes; the nodes may not start any connection. +ensure_acl lincodex-labmgmt +lxc network acl rule add lincodex-labmgmt ingress action=allow protocol=tcp \ + source=10.81.0.1/32 destination_port=22,8728,8729 2>/dev/null || true + +# Guests get static addresses from the provisioner (cloud-init), so no DHCP +# or DNS rule exists: a guest cannot send anything towards the host. +lxc network acl list diff --git a/deploy/labs/lxd-preseed.yaml b/deploy/labs/lxd-preseed.yaml new file mode 100644 index 0000000..d1d9f25 --- /dev/null +++ b/deploy/labs/lxd-preseed.yaml @@ -0,0 +1,68 @@ +# LXD host layout for the isolated runner and the practical labs (TASK-592). +# Applied once on the app host with: lxd init --preseed < lxd-preseed.yaml +# It only adds objects; it does not touch Docker, wg0 or the awg-lincodex tunnel. +storage_pools: + # Copy-on-write pool, so lab nodes are cloned from prepared snapshots in seconds. + - name: lincodex + driver: btrfs + config: + size: 40GiB +networks: + # The runner VM. Only the backend reaches it; the ACL below drops everything else. + - name: lxdbr-runner + type: bridge + config: + ipv4.address: 10.80.0.1/24 + ipv4.nat: "false" + ipv6.address: none + ipv4.dhcp: "false" + raw.dnsmasq: port=0 + security.acls: lincodex-runner + security.acls.default.ingress.action: drop + security.acls.default.egress.action: drop + # Management plane of the labs (checker and console gateway). Lab data links + # are separate L2-only bridges created per lab by the provisioner. + - name: lxdbr-labmgmt + type: bridge + config: + ipv4.address: 10.81.0.1/24 + ipv4.nat: "false" + ipv6.address: none + ipv4.dhcp: "false" + raw.dnsmasq: port=0 + security.acls: lincodex-labmgmt + security.acls.default.ingress.action: drop + security.acls.default.egress.action: drop +profiles: + - name: lincodex-runner + description: Runner VM, 2 vCPU and 3 GiB (PRD Q11.1) + config: + limits.cpu: "2" + limits.memory: 3GiB + limits.memory.enforce: hard + security.secureboot: "false" + devices: + root: + type: disk + path: / + pool: lincodex + size: 10GiB + eth0: + type: nic + network: lxdbr-runner + - name: lincodex-lab-small + description: One lab node, 1 vCPU and up to 768 MiB + config: + limits.cpu: "1" + limits.memory: 768MiB + limits.memory.enforce: hard + security.secureboot: "false" + devices: + root: + type: disk + path: / + pool: lincodex + size: 4GiB + eth0: + type: nic + network: lxdbr-labmgmt diff --git a/docs/en/DEPLOY.md b/docs/en/DEPLOY.md index e3eb39c..41590c0 100644 --- a/docs/en/DEPLOY.md +++ b/docs/en/DEPLOY.md @@ -710,6 +710,31 @@ When the local resolver does not return the public address, add `--resolve