The experiment documents record what was found. These record what to type to
reproduce it, in folders per stage.
Two kinds of command are kept apart. 하기/확인 is what somebody actually types
at a terminal — short, one at a time. 근거를 재려면 is the long measuring form
this lab used to put evidence in a document, marked as not needed day to day.
The same split applies to curl: -I to look once, -w '%{http_code}' only when
comparing across repetitions.
No placeholders. Where a value is needed the command that produces it is
given, and secrets are checked by length rather than printed:
TOKEN=$(ssh kc-lab-1 'sudo cat /var/lib/rancher/k3s/server/node-token')
echo "${#TOKEN} 자"
Stage 05 verifies resources in layers, because a Secret existing and a pod
having received it are different facts: keys, then length, then the value
inside the container, then which env var came from which Secret. Same for
workloads — Deployment to ReplicaSet to Pod, with the seven ReplicaSets this
cluster actually carries as the worked example.
Two commands were wrong and re-running them caught it. kubectl get endpoints
prints a deprecation warning on v1.33+, so the guide uses describe svc and
EndpointSlice. And the Keycloak image has no curl, so reading metrics from
inside the container fails with exit 127 — the guide asks Prometheus instead,
or runs a throwaway curl pod.
Read-only checks were executed against the running lab and their output is
quoted verbatim. Creating commands could not be re-run without destroying the
lab, so they are the ones used at build time; the README says which is which.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
155 lines
3.7 KiB
Markdown
155 lines
3.7 KiB
Markdown
# 00 — lab host 준비
|
|
|
|
## 이 단계가 끝나면
|
|
|
|
`virsh list` 가 sudo 없이 돌고, VM 을 만들 수 있는 상태가 된다.
|
|
|
|
## 전제
|
|
|
|
물리 기계 한 대. 이 실험대는 Arch Linux 를 썼지만 배포판은 상관없다 —
|
|
패키지 이름만 다르다.
|
|
|
|
---
|
|
|
|
## 1. CPU 가상화가 켜져 있는가
|
|
|
|
BIOS 에서 꺼져 있으면 아무것도 못 한다. 먼저 본다.
|
|
|
|
**확인**
|
|
```bash
|
|
grep -Eo 'vmx|svm' /proc/cpuinfo | head -1
|
|
```
|
|
|
|
`vmx`(Intel) 또는 `svm`(AMD) 이 나오면 된다. 아무것도 안 나오면 BIOS 에서
|
|
Intel VT-x / AMD-V 를 켜야 한다.
|
|
|
|
**실측** — 이 실험대의 호스트는 16 코어 전부에서 지원한다.
|
|
|
|
## 2. KVM 모듈이 올라와 있는가
|
|
|
|
**확인**
|
|
```bash
|
|
lsmod | grep kvm
|
|
```
|
|
|
|
```
|
|
kvm_intel ...
|
|
kvm ...
|
|
```
|
|
|
|
두 줄이 나오면 커널이 하드웨어 가상화를 쓸 준비가 됐다.
|
|
|
|
> **왜 이걸 먼저 보나.** KVM 없이도 QEMU 는 돌지만 **소프트웨어 에뮬레이션**이
|
|
> 되어 수십 배 느리다. VM 두 대가 「뜨긴 뜨는데 느리다」면 대개 여기다.
|
|
|
|
## 3. 패키지 설치
|
|
|
|
**하기** (Arch)
|
|
```bash
|
|
sudo pacman -S --needed qemu-full libvirt virt-install dnsmasq
|
|
```
|
|
|
|
Debian/Ubuntu 면 이름이 다르다.
|
|
```bash
|
|
sudo apt install qemu-system-x86 libvirt-daemon-system virtinst cloud-image-utils
|
|
```
|
|
|
|
| 무엇 | 하는 일 |
|
|
|---|---|
|
|
| qemu | 실제로 가상 기계를 돌리는 것 |
|
|
| libvirt | qemu 를 관리하는 층 (`virsh` 가 여기 붙는다) |
|
|
| virt-install | VM 을 만드는 명령 |
|
|
| dnsmasq | 가상 네트워크의 DHCP·DNS |
|
|
|
|
## 4. libvirt 를 띄우고 권한을 받는다
|
|
|
|
**하기**
|
|
```bash
|
|
sudo systemctl enable --now libvirtd.socket
|
|
sudo usermod -aG libvirt "$USER"
|
|
```
|
|
|
|
그리고 **로그아웃했다 다시 들어온다.** 보조 그룹은 로그인할 때 정해지므로
|
|
`usermod` 만으로는 지금 셸에 반영되지 않는다.
|
|
|
|
**확인**
|
|
```bash
|
|
groups # libvirt 가 보여야 한다
|
|
virsh list --all # sudo 없이 돌아야 한다
|
|
```
|
|
|
|
**실측**
|
|
```
|
|
donghyeon libvirt wheel
|
|
```
|
|
|
|
> **`libvirtd.service` 가 아니라 `.socket` 을 켠 이유.** 소켓 활성화라서
|
|
> 데몬이 미리 떠 있지 않아도 `virsh` 가 접속하는 순간 systemd 가 띄운다.
|
|
> 자원을 아끼고, 데몬을 재시작해도 클라이언트가 끊기지 않는다.
|
|
|
|
## 5. 연결 URI 를 고정한다
|
|
|
|
`virsh` 는 기본으로 `qemu:///session`(사용자 단위)에 붙는데, VM 은
|
|
`qemu:///system`(시스템 단위)에 만들어야 한다. **이걸 안 맞추면 만든 VM 이
|
|
안 보인다.**
|
|
|
|
**하기** — 셸 프로필에 넣는다
|
|
```bash
|
|
echo 'export LIBVIRT_DEFAULT_URI=qemu:///system' >> ~/.bashrc
|
|
```
|
|
|
|
**확인**
|
|
```bash
|
|
virsh uri
|
|
```
|
|
```
|
|
qemu:///system
|
|
```
|
|
|
|
## 6. 기본 네트워크
|
|
|
|
**확인**
|
|
```bash
|
|
virsh net-list --all
|
|
```
|
|
|
|
**실측**
|
|
```
|
|
Name State Autostart Persistent
|
|
--------------------------------------------
|
|
default active yes yes
|
|
```
|
|
|
|
`inactive` 면 켠다.
|
|
```bash
|
|
virsh net-start default
|
|
virsh net-autostart default
|
|
```
|
|
|
|
이 네트워크가 `virbr0` 브리지와 `192.168.122.0/24` 대역을 만든다. VM 들이
|
|
여기 붙는다.
|
|
|
|
---
|
|
|
|
## 막히면
|
|
|
|
| 증상 | 원인 | 확인 |
|
|
|---|---|---|
|
|
| `virsh list` 에 permission denied | 그룹 반영 안 됨 | 로그아웃/로그인 했는가. `groups` 에 libvirt 가 있는가 |
|
|
| 만든 VM 이 목록에 없다 | URI 가 `session` | `virsh uri` |
|
|
| VM 이 극단적으로 느리다 | KVM 미사용 | `lsmod \| grep kvm` · BIOS |
|
|
| `net-start default` 실패 | dnsmasq 없음 | 패키지 설치 확인 |
|
|
|
|
---
|
|
|
|
## 이 단계의 실측값
|
|
|
|
돌고 있는 실험대에서 그대로 읽은 것이다.
|
|
|
|
```
|
|
libvirt 12.7.0
|
|
qemu QEMU emulator version 11.1.1
|
|
그룹 donghyeon libvirt wheel
|
|
네트워크 default / active / autostart yes
|
|
```
|