From 6a54e8bbc3637dbf99c78db9a7c30bebf4babb37 Mon Sep 17 00:00:00 2001 From: kaffa Date: Tue, 21 Apr 2026 11:48:37 +0900 Subject: [PATCH] add infra/platform/ollama.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kr1 호스트의 Ollama 런타임 정본 기록. Tailscale 11434 엔드포인트, qwen3:4b / gemma4:e4b 모델, 2026-04-21 tool-calling 검증 내역 포함. --- infra/platform/_index.md | 3 +- infra/platform/ollama.md | 77 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 infra/platform/ollama.md diff --git a/infra/platform/_index.md b/infra/platform/_index.md index 687d212..904d93b 100644 --- a/infra/platform/_index.md +++ b/infra/platform/_index.md @@ -1,6 +1,6 @@ --- title: platform 인덱스 -updated: 2026-04-16 +updated: 2026-04-21 tags: [moc, platform] --- @@ -14,5 +14,6 @@ tags: [moc, platform] | [[infra-forge]] | Forge 인프라 에이전트 (지식 베이스 + LLM 보고) | | [[infra-tofu]] | 인프라 프로비저닝 (OpenTofu) | | [[kaniko]] | Kaniko K8s 네이티브 컨테이너 이미지 빌드 | +| [[ollama]] | Ollama LLM 로컬 추론 엔드포인트 (kr1 호스트) | | [[outline]] | Outline Wiki (팀 문서 관리) | | [[victorialogs]] | VictoriaLogs K3s 로그 저장소 | diff --git a/infra/platform/ollama.md b/infra/platform/ollama.md new file mode 100644 index 0000000..1ebcd5e --- /dev/null +++ b/infra/platform/ollama.md @@ -0,0 +1,77 @@ +--- +title: Ollama — LLM 로컬 추론 엔드포인트 +updated: 2026-04-21 +tags: [infra, llm, ollama, inference] +--- + +## 개요 + +kr1 호스트에 직접 설치된 Ollama 런타임. 컨테이너 아닌 **호스트 systemd service**. tailnet 전체에서 단일 엔드포인트로 공유. + +| 항목 | 값 | +|------|-----| +| 위치 | incus-kr1 호스트 (컨테이너 아님) | +| 서비스 | `ollama.service` (systemd, User=ollama, Restart=always) | +| 버전 | 0.20.2 | +| 바이너리 | `/usr/local/bin/ollama` | +| 엔드포인트 | `http://100.84.111.28:11434` (Tailscale IP, tailnet 공유) | +| 바인딩 | `0.0.0.0:11434` (`OLLAMA_HOST=0.0.0.0`) | +| 인증 | 없음 (tailnet 내부 전용, WAN 노출 아님) | +| 모델 저장소 | `/usr/share/ollama/.ollama` (12GB 사용) | +| Keep-alive | 무제한 (`OLLAMA_KEEP_ALIVE=-1`) — 모델 언로드 안 함 | + +## 설치된 모델 + +| 모델 | 크기 | Capability | 용도 | +|------|------|------------|------| +| `qwen3:4b-instruct-2507-q4_K_M` | 2.5 GB | tools | 경량 tool-calling, 빠른 응답 | +| `gemma4:e4b` | 9.6 GB | tools, thinking, vision, audio | 멀티모달 + tool-calling, 에이전트 기본값 | + +Capability는 `/api/show` 응답의 `capabilities` 필드로 확인. + +## 접근 방법 + +### 모델 목록 +```bash +curl -sS http://100.84.111.28:11434/api/tags | jq +``` + +### Tool-calling chat (OpenAI-style) +```bash +curl -sS http://100.84.111.28:11434/api/chat -d '{ + "model": "gemma4:e4b", + "messages": [{"role":"user","content":"..."}], + "tools": [ { "type":"function", "function": {...} } ], + "stream": false, + "options": {"temperature": 0.2, "num_ctx": 8192} +}' +``` + +### 모델 pull (필요 시) +ollama 사용자만 가능. kr1 호스트에서: +```bash +sudo -u ollama ollama pull +``` + +## 검증된 용도 + +| 일시 | 용도 | 결과 | +|------|------|------| +| 2026-04-21 | `agent.py` stdio 에이전트 루프 (gemma4:e4b, tools 2개, Obsidian 탐색) | 6턴 만에 최종 답변 성공. tool calling·한국어 응답 정상. `~/experiments/ollama-agent/` | + +## 보안 + +- **바인딩은 `0.0.0.0`이지만 노출 범위는 tailnet에 한정**. kr1 호스트의 외부 인터페이스(WAN)는 방화벽으로 차단. Tailscale을 통해서만 11434 포트 도달 가능. +- 인증·TLS 없음. 별도 프록시를 붙이지 않음 (tailnet 신뢰 경계로 충분). +- OpenClaw·ops-agent 등 다수 클라이언트가 공유할 경우 개별 API 키 구분 불가 → 사용처는 OpenMemory/Obsidian에 명시 기록. + +## 운영 주의점 + +- kr1 호스트 자원을 LLM inference가 점유 (모델 로드 시 메모리 압박 가능). heimdall·brokkr·postgres-2·mariadb-2도 같은 호스트라는 점 유의. +- `OLLAMA_KEEP_ALIVE=-1`이라 한 번 로드된 모델은 OOM 전까지 메모리 상주. 모델 전환 시 이전 모델 수동 언로드 필요 (`/api/generate` 호출 시 `keep_alive: 0`). +- 모델 저장소 `/usr/share/ollama/.ollama` 는 호스트 로컬 디스크. 백업 대상 아님 (모델은 재다운로드 가능). + +## 참조 + +- [[infra-hosts]] — kr1 Tailscale IP 100.84.111.28 +- [[../../openclaw/openclaw-ollama|openclaw-ollama]] — OpenClaw의 Ollama 통합 (remote baseUrl 설정 패턴 재사용 가능)