Skip to content

Incus 런타임 및 웹 전용 모드 지원 - #2

Open
tasoo-oos wants to merge 2 commits into
sunghyun1000:mainfrom
tasoo-oos:feat/imsi-web-only
Open

tasoo-oos wants to merge 2 commits into
sunghyun1000:mainfrom
tasoo-oos:feat/imsi-web-only

Conversation

@tasoo-oos

@tasoo-oos tasoo-oos commented Sep 10, 2026

Copy link
Copy Markdown
Contributor
English

Summary

Adds support for the Incus runtime (no snapd required) and a web-terminal-only mode for hosts without secondary/public IPs. The existing LXD (snap) path is unchanged.

Changes

  1. Runtime selection (CONTAINER_RUNTIME: lxd (default, snap) or incus (Zabbly apt repo, no snap). Client/daemon commands, bridge (lxdbr0/incusbr0), image (ubuntu:24.04/images:ubuntu/noble), group (lxd/incus-admin), storage path, and init command are derived per runtime.
  2. Web-only mode: ENABLE_PUBLIC_IPS=0 skips NetworkManager secondary IPs and nftables DNAT/SNAT; ENABLE_CADDY=0 skips Caddy and exposes the app via BIND_ADDRESS. Bridge/container addressing is configurable to avoid host subnet collisions.
  3. Container settings: CONTAINER_MEMORY, CONTAINER_SWAP, CONTAINER_EXTRA_PACKAGES, and CONTAINER_SSH_ENABLED (default off), plus a file capability so non-root users can run ping.
  4. Bug fixes: init detection now checks the default storage pool (a fresh daemon already seeds the default profile); limits.memory.swap byte values are Incus-only (LXD requires bool); CONTAINER_EXTRA_PACKAGES is passed via exec --env / a child-process env object instead of being expanded by the host shell; SECONDARY_IPS is pre-declared for set -u; README manual install and env docs updated.

Verification

Created/rebuilt 6 containers on Ubuntu 24.04 with Incus 7.4 (Zabbly): student auth against /etc/shadow, admin API, xterm.js WebSocket terminal, and the reset queue all work. Each container has 2 GB RAM + 2 GB swap, SSH disabled by default, and the standard toolset installed.

Notes

On Incus/cgroup2 with a hard memory limit, limits.memory.swap=true results in no swap, so the value is converted to a byte size equal to the memory limit for Incus only. The LXD path is unchanged.

개요

snapd 없이 동작하는 Incus 런타임을 추가하고, Secondary/공인 IP가 없는 환경에서도 브라우저 터미널만으로 운영할 수 있는 웹 전용 모드를 추가했습니다. 기존 LXD(snap) 경로는 그대로 유지됩니다.

주요 변경 사항

1. 컨테이너 런타임 선택 (CONTAINER_RUNTIME)

  • lxd(기본, snap) 또는 incus(Zabbly apt 저장소, snap 불필요)를 선택할 수 있습니다.
  • 런타임에 따라 클라이언트/데몬 명령, 브리지(lxdbr0/incusbr0), 이미지(ubuntu:24.04/images:ubuntu/noble), 그룹(lxd/incus-admin), 저장소 경로, 초기화 명령(lxd init/incus admin init)을 자동 선택합니다.

2. 웹 전용 모드

  • ENABLE_PUBLIC_IPS=0: NetworkManager Secondary IP 설정과 nftables DNAT/SNAT 구성을 생략합니다.
  • ENABLE_CADDY=0: Caddy를 생략하고 BIND_ADDRESS로 웹앱을 직접 노출합니다.
  • 호스트 대역과 겹치지 않도록 LXD_BRIDGE_IP/LXD_BRIDGE_SUBNET/CONTAINER_IP_PREFIX를 설정할 수 있습니다.

3. 컨테이너 설정 변수

  • CONTAINER_MEMORY, CONTAINER_SWAP: 메모리 제한과 swap (기본 true = 메모리와 동일 크기).
  • CONTAINER_EXTRA_PACKAGES: 생성 시 설치할 패키지 목록.
  • CONTAINER_SSH_ENABLED: sshd 활성화 여부 (기본 0, openssh-server는 설치됨).
  • 비루트 사용자 ping을 위한 파일 capability를 부여합니다.

4. 버그 수정

  • 신규 호스트에서 profile show default가 init 전에도 성공해 초기화가 건너뛰어지던 문제 → storage listdefault 풀 존재 여부로 판단합니다.
  • limits.memory.swap 바이트 값은 LXD에서 거부(bool만 허용)되므로 Incus일 때만 변환합니다.
  • CONTAINER_EXTRA_PACKAGES가 호스트 셸에서 확장/실행되던 문제 → exec --env로 전달하고, 리셋 경로는 child-process env 객체를 사용합니다.
  • set -u에서 미정의 SECONDARY_IPS 접근 시 에러 → 빈 배열을 사전 선언합니다.
  • README 수동 설치 절차(치환 목록, systemctl 재시작)와 보안/환경변수 문서를 갱신했습니다.

검증

  • Ubuntu 24.04 호스트, Incus 7.4(Zabbly 저장소)에서 6개 컨테이너 생성/재생성을 확인했습니다.
  • 학생 인증(/etc/shadow 대조), 관리자 API, xterm.js WebSocket 터미널, 초기화 큐 동작을 확인했습니다.
  • 컨테이너별 2GB RAM + 2GB swap, SSH 기본 비활성, 표준 도구 설치를 확인했습니다.

참고

  • Incus/cgroup2 + 하드 메모리 제한에서 limits.memory.swap=true는 swap 0이 되므로, Incus에 한해 메모리 크기의 바이트 값으로 자동 변환합니다.
  • 기존 LXD 경로는 동작/설정이 바뀌지 않습니다.

- Add CONTAINER_RUNTIME (lxd|incus); install Incus from the Zabbly apt repo (no snap)
- Add ENABLE_PUBLIC_IPS/ENABLE_CADDY/BIND_ADDRESS for web-terminal-only mode
- Make bridge/container IPs, memory/swap, extra packages, and SSH enablement configurable
- Fix init probe (storage pool), LXD bool vs Incus byte swap, package-list injection/quoting
- Update README manual install steps and env var docs

@sunghyun1000 sunghyun1000 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 가지 중요한 문제가 보입니다. PR에서 Incus용 브리지로 incusbr0를 추가했는데, 기존 outbound abuse 차단 규칙은 여전히 iifname "lxdbr0"로 고정되어 있습니다. 이 때문에 Incus를 사용할 경우 SMTP(25/465/587)나 BitTorrent 트래픽 차단이 제대로 적용되지 않을 수 있습니다.

또 ENABLE_PUBLIC_IPS=0인 경우에는 nftables 설정 자체를 건너뛰고 있어서, 웹 전용 모드에서도 동일하게 abuse 차단 규칙이 빠지게 됩니다. Public IP 사용 여부와 outbound abuse 차단은 별개의 설정으로 분리하는 게 좋을 것 같습니다.

- Template abuse-block.nft with __LXD_BRIDGE_NAME__ so Incus uses incusbr0
- Apply abuse blocking in both public-IP and web-only modes; only student-nat DNAT/SNAT stays gated behind ENABLE_PUBLIC_IPS
- Load br_netfilter and configure the firewalld trusted zone unconditionally
- Update README nftables manual steps
@tasoo-oos

Copy link
Copy Markdown
Contributor Author

지적 감사합니다. 맞는 문제라 수정했습니다 (9bae3d4).

  • config/abuse-block.nft__LXD_BRIDGE_NAME__ 템플릿으로 바꿔 런타임 브리지(Incus=incusbr0, LXD=lxdbr0)로 렌더링하도록 했습니다.
  • abuse 차단을 ENABLE_PUBLIC_IPS와 분리해 두 모드에서 모두 적용하고, student-nat(DNAT/SNAT)만 ENABLE_PUBLIC_IPS=1일 때 생성하도록 했습니다.
  • br_netfilter 로드와 firewalld trusted 존 설정도 모드와 무관하게 수행합니다.
  • README nftables 수동 설치 절차도 템플릿 렌더링 기준으로 갱신했습니다.

검증: ENABLE_PUBLIC_IPS=0 상태에서 incusbr0 규칙이 적용됨을 확인했고, server0sv3:6881 연결이 DROP되고 규칙 카운터가 증가하는 것까지 확인했습니다.

@tasoo-oos
tasoo-oos marked this pull request as ready for review September 10, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants