Files
obsidian/infra/zlambda.md
kappa 2356b86d36 obsidian: 정본 문서에서 히스토리/인시던트 분리 완료
15개 정본 문서에서 날짜별 변경이력, 인시던트 기록, 폐기된 구현 상세를
history/ 디렉토리로 분리. 정본은 현재 상태만 기술하는 백서 형태로 정리.
각 정본에 history 위키링크 추가.

분리된 history 파일 12건:
- apisix git push 500, k3s postgresql migration, apisix→traefik 전환
- netbis DDoS 공격, gitea 이전/분리, usb 2.5g hang + NFS hard mount
- supabase→patroni, apisix etcd 통합/분리, anomaly-detect 재설계
- patroni failover incident, zlambda nixos migration, ops-agents setup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 12:09:21 +09:00

6.1 KiB

title, updated, aliases, tags
title updated aliases tags
zlambda (Linode 도쿄, NixOS) 2026-04-08
sandbox-tokyo
sandbox-tokyo-nixos
nixos
linode
zlambda
infra

개요

Linode Tokyo VM (라벨 zlambda, id 47271589). NixOS 25.05 (Warbler), nixos-anywhere로 설치. 옛 이름 sandbox-tokyo는 Mac ssh config alias로만 남아 있음.

NixOS 전환 이력: ../history/2026-04-08-zlambda-nixos-migration

접속

방법 명령
Tailscale (정식) ssh root@zlambda (100.78.51.18)
Tailscale (alias) ssh root@sandbox-tokyo ← Mac ssh config alias로만 동작
공인 IP ssh root@139.162.71.52
LISH 콘솔 ssh -tt netbis@lish-tokyo2.linode.com zlambda (Linode profile.authorized_keys에 kaffa-Macmini RSA 등록 필요)

Linode 설정

항목
라벨 zlambda
ID 47271589
타입 g6-standard-1 (1 vCPU, 2GB RAM, 50GB SSD)
리전 ap-northeast (Tokyo, lish-tokyo2)
공인 IP 139.162.71.52
Configuration profile "NixOS Direct Disk" (id 99124808)
Kernel linode/direct-disk ← Linode emulated GRUB은 NixOS grub.cfg를 못 읽어서 변경
디스크 sda 121448048, ext4, 50688 MB → /
디스크 sdb 121448049, swap, 512 MB → swap
Linode Firewall id 691875 "zlambda" — TCP22(any), TCP80/443(Cloudflare), UDP41641(any), ICMP(any), default DROP
Linode API token Vault secret/cloud/linode (netbis 계정용)

디스크 레이아웃

sda (49.5G)
├── sda1 (1M)   BIOS boot partition (EF02)
└── sda2 (49.5G) ext4, mountpoint /
sdb (512M)
└── sdb1 (510M) swap

GRUB은 BIOS-GPT 방식, sda MBR + BIOS boot partition + /boot inside / fs.

NixOS Configuration

Gitea 저장소: https://gitea.inouter.com/kaffa/nixos-infra (private)

nixos-infra/
├── README.md
├── .gitignore
├── flake.nix                    # disko + nixpkgs 25.05
├── flake.lock                   # 잠긴 input 버전
├── configuration.nix            # 메인 설정
└── hardware-configuration.nix   # nixos-anywhere가 자동 생성

clone 위치:

  • kaffa-macmini: ~/nixos-infra/ (작성/수정용, push 권한). remote는 토큰 임베드 https URL
  • zlambda: /root/nixos-infra/ (실제 빌드/적용용). remote는 SSH (git@gitea.inouter.com:kaffa/nixos-infra.git), gitea repo deploy key 등록됨 (/root/.ssh/gitea_nixos_infra, read-only, fingerprint SHA256:Amz8LUDKHU59qxyMS48hfoP+KxRE/o6CITfkXzkAFNU)
  • macbookair: 아직 clone 안 함 (필요 시 git clone https://gitea.inouter.com/kaffa/nixos-infra.git)

향후 두 번째 NixOS 노드 추가 시 hosts/<name>/ 구조로 재편 예정 (README.md 참조).

flake input:

  • nixpkgs: github:NixOS/nixpkgs/nixos-25.05
  • disko: github:nix-community/disko

활성화된 모듈/서비스:

  • networking.hostName = "zlambda"
  • services.openssh (PermitRootLogin prohibit-password, PasswordAuth off)
  • services.tailscale.enable = true
  • virtualisation.docker.enable = true (autoPrune 켜짐)
  • virtualisation.oci-containers.backend = "docker" (apisix.nix 모듈에서 apisix + apisix-etcd 선언)
  • nix.settings.experimental-features = [ "nix-command" "flakes" ]
  • 패키지: vim git curl wget htop tmux jq rsync
  • TZ: Asia/Tokyo, locale en_US.UTF-8
  • networking.firewall.enable = false (Linode firewall에 일임)
  • system.stateVersion = "25.05"

apisix.nix 모듈 요약:

  • 컨테이너: apisix(172.22.222.20), apisix-etcd(172.22.222.3), docker network apisix-net (172.22.222.0/24)
  • 포트: 80→9080, 443→9443, 9180(admin)
  • 데이터: etcd는 /var/lib/apisix/etcd bind mount, apisix 로그는 named volume apisix-logs
  • config.yaml은 템플릿(Nix store) + 런타임 렌더링(apisix-render-config.service) → /run/apisix/config.yaml 후 read-only bind mount. admin key는 자리표시자 __ADMIN_KEY__로 들어있고 render 서비스가 agenix 복호화 값으로 sed 치환.
  • systemd 의존성: init-apisix-net.service(oneshot network 생성) → docker-apisix-etcd; apisix-render-config.service(oneshot) + init-apisix-net.servicedocker-apisix
  • 시크릿: agenix(secrets/apisix-admin-key.age) → activation 시 /run/agenix/apisix-admin-key로 복호화. zlambda host ed25519 키와 kaffa 사용자 ed25519 키 두 개로 암호화됨.
  • 상세 운영: netbis

커널 / sysctl 튜닝 (2026-04-08 추가):

  • boot.kernelModules = [ "br_netfilter" ] (docker bridge sysctl 활성화용)
  • 네트워크: BBR + fq qdisc, somaxconn 4096, tcp_fin_timeout 15, tcp_tw_reuse, tcp_keepalive 600/30/6, netdev_max_backlog 16384, tcp_max_syn_backlog 8192
  • 포워딩: ip_forward, IPv6 forwarding, bridge-nf-call-{ip,ip6}tables (docker)
  • 메모리: vm.swappiness=10, vm.overcommit_memory=1, vm.dirty_ratio=10/5
  • 파일/inotify: file-max=1048576, inotify watches=524288, instances=8192, queued_events=65536
  • 콘솔: kernel.printk = "3 4 1 3"

GRUB 설정: disko의 EF02 파티션이 자동으로 grub.devices를 채워주므로 boot.loader.grub.devices는 명시하지 않음 (명시하면 mirroredBoots 중복 오류 남).

재배포/변경 방법

1. 호스트에서 직접 rebuild (권장, 가장 빠름)

# kaffa-macmini에서 변경
cd ~/nixos-infra
$EDITOR configuration.nix
git add -A && git commit -m "..." && git push

# zlambda에서 적용 (deploy key 자동 인증)
ssh root@zlambda
cd /root/nixos-infra
git pull
nixos-rebuild switch --flake .#zlambda

2. macOS에서 원격 rebuild는 권장하지 않음

macOS는 aarch64-darwin이라 x86_64-linux용 nixos-rebuild 래퍼를 native build 못 함. 시도하면 cross-build 단계에서 실패하거나 한참 걸림. 대신 호스트에서 직접 rebuild 권장. 필요 시 kaffa-macmini에 linux-builder VM을 켜면 가능.

3. nixos-anywhere로 처음부터 재설치 (디스크 wipe)

cd ~/nixos-infra
nix run github:nix-community/nixos-anywhere -- \
  --flake .#zlambda --build-on remote \
  root@139.162.71.52

후속 작업

  • vault SSH CA에 새 호스트키 등록 (vault.md 참조)
  • 필요 시 netbis APISIX/etcd Docker compose 재배포
  • 필요 시 searxng용 tlsproxy/microsocks 재배포