# Site11 - Multi-Language News Platform with Microservices Architecture ## ๐Ÿ“‹ ๋ชฉ์ฐจ (Table of Contents) - [๊ฐœ์š” (Overview)](#๊ฐœ์š”-overview) - [์‹œ์Šคํ…œ ์š”๊ตฌ์‚ฌํ•ญ (System Requirements)](#์‹œ์Šคํ…œ-์š”๊ตฌ์‚ฌํ•ญ-system-requirements) - [๋น ๋ฅธ ์‹œ์ž‘ (Quick Start)](#๋น ๋ฅธ-์‹œ์ž‘-quick-start) - [์ƒ์„ธ ์„ค์น˜ ๊ฐ€์ด๋“œ (Detailed Installation)](#์ƒ์„ธ-์„ค์น˜-๊ฐ€์ด๋“œ-detailed-installation) - [์„œ๋น„์Šค ๊ตฌ์กฐ (Service Architecture)](#์„œ๋น„์Šค-๊ตฌ์กฐ-service-architecture) - [์„œ๋น„์Šค ๊ด€๋ฆฌ (Service Management)](#์„œ๋น„์Šค-๊ด€๋ฆฌ-service-management) - [ํ™˜๊ฒฝ ์„ค์ • (Configuration)](#ํ™˜๊ฒฝ-์„ค์ •-configuration) - [๊ฐœ๋ฐœ ๊ฐ€์ด๋“œ (Development Guide)](#๊ฐœ๋ฐœ-๊ฐ€์ด๋“œ-development-guide) - [๋ฌธ์ œ ํ•ด๊ฒฐ (Troubleshooting)](#๋ฌธ์ œ-ํ•ด๊ฒฐ-troubleshooting) - [Git ์ €์žฅ์†Œ ๊ด€๋ฆฌ (Repository Management)](#git-์ €์žฅ์†Œ-๊ด€๋ฆฌ-repository-management) ## ๊ฐœ์š” (Overview) Site11์€ ๋‹ค๊ตญ์–ด ๋‰ด์Šค ์ฝ˜ํ…์ธ ๋ฅผ ์ž๋™์œผ๋กœ ์ˆ˜์ง‘, ๋ฒˆ์—ญ, ์ƒ์„ฑํ•˜๋Š” ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ๊ธฐ๋ฐ˜ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ### ์ฃผ์š” ๊ธฐ๋Šฅ - ๐ŸŒ 8๊ฐœ ์–ธ์–ด ์ž๋™ ๋ฒˆ์—ญ (ํ•œ๊ตญ์–ด, ์˜์–ด, ์ค‘๊ตญ์–ด, ์ผ๋ณธ์–ด, ํ”„๋ž‘์Šค์–ด, ๋…์ผ์–ด, ์ŠคํŽ˜์ธ์–ด, ์ดํƒˆ๋ฆฌ์•„์–ด) - ๐Ÿ“ฐ ์‹ค์‹œ๊ฐ„ ๋‰ด์Šค ์ˆ˜์ง‘ ๋ฐ AI ๊ธฐ๋ฐ˜ ์ฝ˜ํ…์ธ  ์ƒ์„ฑ - ๐ŸŽจ ์ž๋™ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋ฐ ์ตœ์ ํ™” - ๐Ÿ”„ ๋น„๋™๊ธฐ ์ž‘์—… ์ฒ˜๋ฆฌ ํŒŒ์ดํ”„๋ผ์ธ - ๐Ÿ“Š ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ํ†ต๊ณ„ ## ์‹œ์Šคํ…œ ์š”๊ตฌ์‚ฌํ•ญ (System Requirements) ### ํ•„์ˆ˜ ์š”๊ตฌ์‚ฌํ•ญ - **Docker**: 20.10.0 ์ด์ƒ - **Docker Compose**: 2.0.0 ์ด์ƒ - **๋ฉ”๋ชจ๋ฆฌ**: ์ตœ์†Œ 8GB RAM (16GB ๊ถŒ์žฅ) - **๋””์Šคํฌ**: ์ตœ์†Œ 50GB ์—ฌ์œ  ๊ณต๊ฐ„ - **OS**: Linux, macOS, Windows with WSL2 ### ํฌํŠธ ์‚ฌ์šฉ #### ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฐํฌ ํฌํŠธ ๊ตฌ์„ฑ (ํ˜„์žฌ ๊ตฌ์„ฑ) ``` [ Docker Compose - ์ธํ”„๋ผ ์„œ๋น„์Šค ] - 27017: MongoDB (๋‚ด๋ถ€) - 6379: Redis (๋‚ด๋ถ€) - 9092: Kafka (๋‚ด๋ถ€) - 2181: Zookeeper (๋‚ด๋ถ€) - 5555: Docker Registry (๋‚ด๋ถ€) - 8099: Pipeline Scheduler - 8100: Pipeline Monitor [ Kubernetes - ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค (NodePort) ] - 30080: Console Frontend (โ†’ 8080) - 30800: Console Backend API Gateway (โ†’ 8000) - 30801-30802: Images Service (โ†’ 8001-8002) - 30803-30804: OAuth Service (โ†’ 8003-8004) - 30805-30806: Applications Service (โ†’ 8005-8006) - 30807-30808: Users Service (โ†’ 8007-8008) - 30809-30810: Data Service (โ†’ 8009-8010) - 30811-30812: Statistics Service (โ†’ 8011-8012) [ Pipeline Workers (K8s ๋‚ด๋ถ€) ] - RSS Collector - Google Search - Translator - AI Article Generator - Image Generator ``` #### ํ‘œ์ค€ Docker Compose ํฌํŠธ ๊ตฌ์„ฑ (์ „์ฒด Docker ๋ชจ๋“œ) ``` - 3000: Console Frontend - 8000: Console Backend (API Gateway) - 8001-8002: Images Service - 8003-8004: OAuth Service - 8005-8006: Applications Service - 8007-8008: Users Service - 8009-8010: Data Service - 8011-8012: Statistics Service - 8099: Pipeline Scheduler - 8100: Pipeline Monitor - 27017: MongoDB (๋‚ด๋ถ€) - 6379: Redis (๋‚ด๋ถ€) - 9092: Kafka (๋‚ด๋ถ€) - 2181: Zookeeper (๋‚ด๋ถ€) ``` ## ๋น ๋ฅธ ์‹œ์ž‘ (Quick Start) ### 1. ์ €์žฅ์†Œ ํด๋ก  ```bash # HTTPS git clone http://gitea.yakenator.io/aimond/site11.git # ๋””๋ ‰ํ† ๋ฆฌ ์ด๋™ cd site11 ``` ### 2. ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ • ```bash # .env ํŒŒ์ผ ์ƒ์„ฑ cp .env.example .env # ํ•„์ˆ˜ ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ํŽธ์ง‘ (์‹ค์ œ API ํ‚ค๋กœ ๊ต์ฒด ํ•„์š”) vim .env # ๋‹ค์Œ ํ•ญ๋ชฉ๋“ค์„ ์ถ”๊ฐ€: # DEEPL_API_KEY=your-deepl-api-key # OPENAI_API_KEY=your-openai-api-key # CLAUDE_API_KEY=your-claude-api-key # SERP_API_KEY=your-serp-api-key ``` ### 3. ์ „์ฒด ์‹œ์Šคํ…œ ์‹œ์ž‘ ```bash # ๋ชจ๋“  ์„œ๋น„์Šค ๋นŒ๋“œ ๋ฐ ์‹œ์ž‘ (๋ฐฑ๊ทธ๋ผ์šด๋“œ) docker-compose up -d --build # ์ƒํƒœ ํ™•์ธ docker-compose ps # ๋กœ๊ทธ ํ™•์ธ docker-compose logs -f ``` ### 4. ์„œ๋น„์Šค ํ™•์ธ #### ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฐํฌ ํ™•์ธ (ํ˜„์žฌ ๊ตฌ์„ฑ) ```bash # Console Frontend ์ ‘์† (K8s NodePort) open http://localhost:30080 # Console API ํ—ฌ์Šค ์ฒดํฌ (K8s NodePort) curl http://localhost:30800/health curl http://localhost:30800/api/health # Pipeline ๋ชจ๋‹ˆํ„ฐ ํ™•์ธ (Docker) curl http://localhost:8100/health # MongoDB ์—ฐ๊ฒฐ ํ™•์ธ (Docker) docker exec -it site11_mongodb mongosh --eval "db.serverStatus()" # K8s Pod ์ƒํƒœ ํ™•์ธ kubectl -n site11-pipeline get pods kubectl -n site11-pipeline get services ``` #### ํ‘œ์ค€ Docker ํ™•์ธ ```bash # Console Frontend ์ ‘์† open http://localhost:3000 # Console API ํ—ฌ์Šค ์ฒดํฌ curl http://localhost:8000/health # MongoDB ์—ฐ๊ฒฐ ํ™•์ธ docker exec -it site11_mongodb mongosh --eval "db.serverStatus()" # Pipeline ๋ชจ๋‹ˆํ„ฐ ํ™•์ธ curl http://localhost:8100/health ``` ## ์ƒ์„ธ ์„ค์น˜ ๊ฐ€์ด๋“œ (Detailed Installation) ### ๋‹จ๊ณ„๋ณ„ ์„œ๋น„์Šค ์‹œ์ž‘ #### 1๋‹จ๊ณ„: ํ•ต์‹ฌ ์ธํ”„๋ผ ```bash # MongoDB, Redis, Kafka ์‹œ์ž‘ docker-compose up -d mongodb redis zookeeper kafka # ์ธํ”„๋ผ ์ค€๋น„ ๋Œ€๊ธฐ (์•ฝ 30์ดˆ) sleep 30 # ์ƒํƒœ ํ™•์ธ docker-compose ps mongodb redis kafka ``` #### 2๋‹จ๊ณ„: ํ•ต์‹ฌ ๋ฐฑ์—”๋“œ ์„œ๋น„์Šค ```bash # ํ•ต์‹ฌ ์„œ๋น„์Šค ์‹œ์ž‘ docker-compose up -d console-backend users-backend \ oauth-backend images-backend files-backend \ statistics-backend search-backend # ์„œ๋น„์Šค ์ƒํƒœ ํ™•์ธ docker-compose ps | grep backend ``` #### 3๋‹จ๊ณ„: Pipeline ์„œ๋น„์Šค ```bash # Pipeline ์„œ๋น„์Šค ์‹œ์ž‘ docker-compose up -d pipeline-scheduler pipeline-monitor \ pipeline-rss-collector pipeline-google-search \ pipeline-ai-article-generator pipeline-translator \ pipeline-image-generator pipeline-language-sync # Pipeline ๋ชจ๋‹ˆํ„ฐ ํ™•์ธ curl http://localhost:8100/health ``` #### 4๋‹จ๊ณ„: ๋‰ด์Šค ์ƒ์„ฑ ์„œ๋น„์Šค ```bash # ๋‰ด์Šค ๊ด€๋ จ ์„œ๋น„์Šค docker-compose up -d news-aggregator-backend \ ai-writer-backend ai-writer-worker \ google-search-backend rss-feed-backend # AI Writer ์ƒํƒœ ํ™•์ธ curl http://localhost:8019/health ``` #### 5๋‹จ๊ณ„: ํ”„๋ก ํŠธ์—”๋“œ ์„œ๋น„์Šค ```bash # Console ํ”„๋ก ํŠธ์—”๋“œ docker-compose up -d console-frontend # ์›น UI ์ ‘์† # http://localhost:3000 ``` ## ์„œ๋น„์Šค ๊ตฌ์กฐ (Service Architecture) ### ํ•ต์‹ฌ ์ธํ”„๋ผ - **MongoDB**: ๋ฐ์ดํ„ฐ ์ €์žฅ์†Œ - **Redis**: ์บ์‹œ ๋ฐ ์ž‘์—… ํ - **Kafka**: ์ด๋ฒคํŠธ ์ŠคํŠธ๋ฆฌ๋ฐ - **MinIO**: ์ด๋ฏธ์ง€/ํŒŒ์ผ ์ €์žฅ์†Œ - **Solr**: ๊ฒ€์ƒ‰ ์—”์ง„ ### Pipeline ์„œ๋น„์Šค ``` pipeline-scheduler (8099) โ”œโ”€โ”€ pipeline-rss-collector # RSS ํ”ผ๋“œ ์ˆ˜์ง‘ โ”œโ”€โ”€ pipeline-google-search # Google ๊ฒ€์ƒ‰ ์ˆ˜์ง‘ โ”œโ”€โ”€ pipeline-ai-generator # AI ์ฝ˜ํ…์ธ  ์ƒ์„ฑ โ”œโ”€โ”€ pipeline-translator # ๋‹ค๊ตญ์–ด ๋ฒˆ์—ญ โ””โ”€โ”€ pipeline-image-generator # ์ด๋ฏธ์ง€ ์ƒ์„ฑ pipeline-monitor (8100) # ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง ``` ### ์ฝ˜ํ…์ธ  ์„œ๋น„์Šค - **Console** (8011/3000): ๊ด€๋ฆฌ ์ฝ˜์†” - **AI Writer** (8019): AI ์ฝ˜ํ…์ธ  ์ƒ์„ฑ - **News Aggregator** (8018): ๋‰ด์Šค ์ˆ˜์ง‘ - **Google Search** (8016): ๊ฒ€์ƒ‰ ์„œ๋น„์Šค - **RSS Feed** (8017): RSS ํ”ผ๋“œ ์ˆ˜์ง‘ ## ์„œ๋น„์Šค ๊ด€๋ฆฌ (Service Management) ### ๊ฐœ๋ณ„ ์„œ๋น„์Šค ๊ด€๋ฆฌ ```bash # ํŠน์ • ์„œ๋น„์Šค๋งŒ ์‹œ์ž‘ docker-compose up -d [service-name] # ํŠน์ • ์„œ๋น„์Šค ์žฌ์‹œ์ž‘ docker-compose restart [service-name] # ํŠน์ • ์„œ๋น„์Šค ์ค‘์ง€ docker-compose stop [service-name] # ์„œ๋น„์Šค ๋กœ๊ทธ ํ™•์ธ docker-compose logs -f [service-name] # ์„œ๋น„์Šค ์žฌ๋นŒ๋“œ docker-compose build [service-name] docker-compose up -d [service-name] ``` ### ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ ```bash # MongoDB ์ ‘์† docker exec -it site11_mongodb mongosh # ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ชฉ๋ก show dbs # AI Writer DB ์‚ฌ์šฉ use ai_writer_db # ์ปฌ๋ ‰์…˜ ํ™•์ธ show collections # ๊ธฐ์‚ฌ ์ˆ˜ ํ™•์ธ db.articles_ko.countDocuments() ``` ### Redis ๊ด€๋ฆฌ ```bash # Redis CLI ์ ‘์† docker exec -it site11_redis redis-cli # ๋ชจ๋“  ํ‚ค ํ™•์ธ KEYS * # ํ ์ƒํƒœ ํ™•์ธ LLEN queue:google_search LLEN queue:ai_generation LLEN queue:translation ``` ## ํ™˜๊ฒฝ ์„ค์ • (Configuration) ### ํ•„์ˆ˜ API ํ‚ค ์„ค์ • ```bash # .env ํŒŒ์ผ ํŽธ์ง‘ vim .env # ํ•„์ˆ˜ ์„ค์ • DEEPL_API_KEY=your-deepl-api-key # ๋ฒˆ์—ญ API OPENAI_API_KEY=your-openai-api-key # ์ด๋ฏธ์ง€ ์ƒ์„ฑ CLAUDE_API_KEY=your-claude-api-key # AI ์ฝ˜ํ…์ธ  ์ƒ์„ฑ SERP_API_KEY=your-serp-api-key # Google ๊ฒ€์ƒ‰ ``` ### Pipeline ์„ค์ • ```bash # services/pipeline/.env ํŒŒ์ผ ์ƒ์„ฑ cat > services/pipeline/.env << EOF DEEPL_API_KEY=your-deepl-api-key OPENAI_API_KEY=your-openai-api-key CLAUDE_API_KEY=your-claude-api-key SERP_API_KEY=your-serp-api-key WORKER_COUNT=3 BATCH_SIZE=10 TRANSLATION_DELAY=1.0 EOF ``` ## ๊ฐœ๋ฐœ ๊ฐ€์ด๋“œ (Development Guide) ### ์ƒˆ ์„œ๋น„์Šค ์ถ”๊ฐ€ ```bash # ์„œ๋น„์Šค ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ services/ โ””โ”€โ”€ new-service/ โ”œโ”€โ”€ backend/ โ”‚ โ”œโ”€โ”€ Dockerfile โ”‚ โ”œโ”€โ”€ requirements.txt โ”‚ โ””โ”€โ”€ main.py โ””โ”€โ”€ frontend/ โ”œโ”€โ”€ Dockerfile โ”œโ”€โ”€ package.json โ””โ”€โ”€ src/ ``` ### ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ```bash # ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ (Python) cd services/[service-name]/backend python -m venv venv source venv/bin/activate pip install -r requirements.txt python main.py # ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ (React) cd services/[service-name]/frontend npm install npm run dev ``` ### ํ…Œ์ŠคํŠธ ์‹คํ–‰ ```bash # ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ python test_integration.py # Pipeline ํ…Œ์ŠคํŠธ python services/pipeline/test_pipeline.py # ํŠน์ • ์„œ๋น„์Šค ํ…Œ์ŠคํŠธ docker exec -it site11_[service-name] pytest ``` ## ๋ฌธ์ œ ํ•ด๊ฒฐ (Troubleshooting) ### ์„œ๋น„์Šค๊ฐ€ ์‹œ์ž‘๋˜์ง€ ์•Š์„ ๋•Œ ```bash # ํฌํŠธ ์ถฉ๋Œ ํ™•์ธ lsof -i :8000 # ์ปจํ…Œ์ด๋„ˆ ์ƒํƒœ ํ™•์ธ docker ps -a | grep site11 # ์˜ค๋ฅ˜ ๋กœ๊ทธ ํ™•์ธ docker-compose logs [service-name] | tail -100 ``` ### MongoDB ์—ฐ๊ฒฐ ๋ฌธ์ œ ```bash # MongoDB ์ƒํƒœ ํ™•์ธ docker exec -it site11_mongodb mongosh --eval "db.serverStatus()" # ์—ฐ๊ฒฐ ํ…Œ์ŠคํŠธ docker run --rm -it --network site11_network mongo:7.0 mongosh mongodb://mongodb:27017 ``` ### ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ ๋ฌธ์ œ ```bash # Docker ๋ฆฌ์†Œ์Šค ์ •๋ฆฌ docker system prune -a # ๋ถˆํ•„์š”ํ•œ ์ด๋ฏธ์ง€ ์‚ญ์ œ docker image prune -a # ์ปจํ…Œ์ด๋„ˆ ๋กœ๊ทธ ์ •๋ฆฌ docker-compose logs --tail=0 --follow ``` ### Pipeline ์ž‘์—… ๋ง‰ํž˜ ```bash # Redis ํ ํ™•์ธ docker exec -it site11_redis redis-cli > LLEN queue:translation > LPOP queue:translation # ๋ง‰ํžŒ ์ž‘์—… ์ œ๊ฑฐ # Pipeline ์žฌ์‹œ์ž‘ docker-compose restart pipeline-scheduler pipeline-translator ``` ## Git ์ €์žฅ์†Œ ๊ด€๋ฆฌ (Repository Management) ### .gitignore ์„ค์ • ``` # ๋Œ€์šฉ๋Ÿ‰ ํŒŒ์ผ ์ œ์™ธ backups/ *.archive *.log data/ # ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ œ์™ธ *.png *.jpg *.jpeg # Node modules ์ œ์™ธ node_modules/ **/node_modules/ # ํ™˜๊ฒฝ ํŒŒ์ผ .env *.env.local ``` ### ์ €์žฅ์†Œ ์ •๋ฆฌ ```bash # Git ํžˆ์Šคํ† ๋ฆฌ ์ •๋ฆฌ git gc --aggressive --prune=now # ๋Œ€์šฉ๋Ÿ‰ ํŒŒ์ผ ์ฐพ๊ธฐ find . -size +100M -type f # ์บ์‹œ ์ •๋ฆฌ git rm -r --cached [file/folder] ``` ## ๋ชจ๋‹ˆํ„ฐ๋ง (Monitoring) ### Pipeline ๋ชจ๋‹ˆํ„ฐ๋ง - URL: http://localhost:8100 - ์‹ค์‹œ๊ฐ„ ํ ์ƒํƒœ ํ™•์ธ - ์ฒ˜๋ฆฌ ํ†ต๊ณ„ ํ™•์ธ ### ๋กœ๊ทธ ๋ชจ๋‹ˆํ„ฐ๋ง ```bash # ์ „์ฒด ๋กœ๊ทธ ์ŠคํŠธ๋ฆผ docker-compose logs -f # ํŠน์ • ์„œ๋น„์Šค ๋กœ๊ทธ docker-compose logs -f pipeline-scheduler # ์—๋Ÿฌ๋งŒ ํ•„ํ„ฐ๋ง docker-compose logs -f 2>&1 | grep ERROR ``` ### ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง ```bash # ์ปจํ…Œ์ด๋„ˆ ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ๋Ÿ‰ docker stats # MongoDB ์„ฑ๋Šฅ docker exec -it site11_mongodb mongosh --eval "db.serverStatus().opcounters" ``` ## ๋ฐฑ์—… ๋ฐ ๋ณต๊ตฌ (Backup & Recovery) ### MongoDB ๋ฐฑ์—… ```bash # ๋ฐฑ์—… ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰ ./scripts/backup-mongodb.sh # ์ˆ˜๋™ ๋ฐฑ์—… docker exec -it site11_mongodb mongodump --archive=/data/backup.archive docker cp site11_mongodb:/data/backup.archive ./backups/ ``` ### ์ „์ฒด ์‹œ์Šคํ…œ ๋ฐฑ์—… ```bash # ๋ฐ์ดํ„ฐ ๋””๋ ‰ํ† ๋ฆฌ ๋ฐฑ์—… tar -czf backup-$(date +%Y%m%d).tar.gz data/ # ์„ค์ • ๋ฐฑ์—… tar -czf config-backup.tar.gz .env docker-compose.yml services/ ``` ## ๋ฌธ์˜ ๋ฐ ์ง€์› (Support) - **์ด์Šˆ ํŠธ๋ž˜์ปค**: http://gitea.yakenator.io/aimond/site11/issues - **๋ฌธ์„œ**: `/docs` ๋””๋ ‰ํ† ๋ฆฌ ์ฐธ์กฐ - `PLAN.md`: ๊ตฌํ˜„ ๊ณ„ํš - `PROGRESS.md`: ์ง„ํ–‰ ์ƒํ™ฉ - `ARCHITECTURE.md`: ์‹œ์Šคํ…œ ๊ตฌ์กฐ - `PIPELINE_SCHEDULER_GUIDE.md`: Pipeline ๊ฐ€์ด๋“œ ## ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฐํฌ (Hybrid Deployment with K8s) Site11์€ Docker Compose์™€ Kubernetes๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฐํฌ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ### ๋ฐฐํฌ ์•„ํ‚คํ…์ฒ˜ #### Docker Compose (์ธํ”„๋ผ ์„œ๋น„์Šค) - **์ธํ”„๋ผ**: MongoDB, Redis, Kafka, Zookeeper - **์ค‘์•™ ์ œ์–ด**: Pipeline Scheduler, Pipeline Monitor, Language Sync - **๋ ˆ์ง€์ŠคํŠธ๋ฆฌ**: Docker Registry (port 5555) #### Kubernetes (์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐ ํŒŒ์ดํ”„๋ผ์ธ) - **๊ด€๋ฆฌ ์ฝ˜์†”**: Console Backend/Frontend - **๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค**: Images, OAuth, Applications, Users, Data, Statistics - **๋ฐ์ดํ„ฐ ์ˆ˜์ง‘**: RSS Collector, Google Search - **์ฒ˜๋ฆฌ ์›Œ์ปค**: Translator, AI Article Generator, Image Generator - **์ž๋™ ์Šค์ผ€์ผ๋ง**: HPA(Horizontal Pod Autoscaler) ์ ์šฉ ### ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฐํฌ ์‹œ์ž‘ #### 1. Docker ์ธํ”„๋ผ ์‹œ์ž‘ ```bash # ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ์šฉ docker-compose ์‚ฌ์šฉ docker-compose -f docker-compose-hybrid.yml up -d # ์ƒํƒœ ํ™•์ธ docker-compose -f docker-compose-hybrid.yml ps # ๋กœ๊ทธ ํ™•์ธ docker-compose -f docker-compose-hybrid.yml logs -f pipeline-scheduler ``` #### 2. Docker Hub๋ฅผ ์‚ฌ์šฉํ•œ K8s ๋ฐฐํฌ (๊ถŒ์žฅ) ```bash # Docker Hub์— ์ด๋ฏธ์ง€ ํ‘ธ์‹œ ./deploy-dockerhub.sh # K8s ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋ฐ ์„ค์ • ์ƒ์„ฑ kubectl create namespace site11-pipeline kubectl -n site11-pipeline apply -f k8s/pipeline/configmap.yaml kubectl -n site11-pipeline apply -f k8s/pipeline/secrets.yaml # Docker Hub ์ด๋ฏธ์ง€๋กœ ๋ฐฐํฌ cd k8s/pipeline for service in console-backend console-frontend \ ai-article-generator translator image-generator \ rss-collector google-search; do kubectl apply -f ${service}-dockerhub.yaml done # ๋ฐฐํฌ ์ƒํƒœ ํ™•์ธ kubectl -n site11-pipeline get pods kubectl -n site11-pipeline get services kubectl -n site11-pipeline get hpa ``` #### 3. ๋กœ์ปฌ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•œ K8s ๋ฐฐํฌ (๋Œ€์•ˆ) ```bash # ๋กœ์ปฌ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ์‹œ์ž‘ (Docker Compose) docker-compose -f docker-compose-hybrid.yml up -d registry # ์ด๋ฏธ์ง€ ๋นŒ๋“œ ๋ฐ ํ‘ธ์‹œ ./deploy-local.sh # K8s ๋ฐฐํฌ cd k8s/pipeline ./deploy.sh # ๋ฐฐํฌ ์ƒํƒœ ํ™•์ธ kubectl -n site11-pipeline get pods kubectl -n site11-pipeline get hpa ``` ### K8s ์ž๋™ ์Šค์ผ€์ผ๋ง ์„ค์ • #### HPA (Horizontal Pod Autoscaler) ๊ตฌ์„ฑ | ์„œ๋น„์Šค | ์ตœ์†Œ Pod | ์ตœ๋Œ€ Pod | CPU ์ž„๊ณ„๊ฐ’ | ๋ฉ”๋ชจ๋ฆฌ ์ž„๊ณ„๊ฐ’ | |--------|---------|---------|------------|-------------| | RSS Collector | 1 | 5 | 70% | 80% | | Google Search | 1 | 5 | 70% | 80% | | Translator | 2 | 10 | 70% | 80% | | AI Generator | 1 | 8 | 70% | 80% | | Image Generator | 1 | 6 | 70% | 80% | #### ์Šค์ผ€์ผ๋ง ๋ชจ๋‹ˆํ„ฐ๋ง ```bash # HPA ์ƒํƒœ ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง kubectl -n site11-pipeline get hpa -w # Pod ์ˆ˜ ํ™•์ธ kubectl -n site11-pipeline get pods -o wide # ๋ฉ”ํŠธ๋ฆญ ์ƒ์„ธ ์ •๋ณด kubectl -n site11-pipeline describe hpa pipeline-translator-hpa # ์ˆ˜๋™ ์Šค์ผ€์ผ๋ง (ํ•„์š”์‹œ) kubectl -n site11-pipeline scale deployment pipeline-translator --replicas=5 ``` ### K8s ์›Œ์ปค ๊ด€๋ฆฌ #### ๋กœ๊ทธ ํ™•์ธ ```bash # ํŠน์ • ๋””ํ”Œ๋กœ์ด๋จผํŠธ ๋กœ๊ทธ kubectl -n site11-pipeline logs -f deployment/pipeline-translator # ๋ชจ๋“  Pod ๋กœ๊ทธ kubectl -n site11-pipeline logs -f -l component=processor # ์—๋Ÿฌ๋งŒ ํ•„ํ„ฐ๋ง kubectl -n site11-pipeline logs -f deployment/pipeline-translator | grep ERROR ``` #### ์—…๋ฐ์ดํŠธ ๋ฐ ๋กค๋ฐฑ ```bash # ์ด๋ฏธ์ง€ ์—…๋ฐ์ดํŠธ kubectl -n site11-pipeline set image deployment/pipeline-translator \ translator=site11/pipeline-translator:v2 # ๋กค์•„์›ƒ ์ƒํƒœ ํ™•์ธ kubectl -n site11-pipeline rollout status deployment/pipeline-translator # ๋กค๋ฐฑ (ํ•„์š”์‹œ) kubectl -n site11-pipeline rollout undo deployment/pipeline-translator ``` #### ๋ฆฌ์†Œ์Šค ๋ชจ๋‹ˆํ„ฐ๋ง ```bash # Pod ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ๋Ÿ‰ kubectl -n site11-pipeline top pods # Node ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ๋Ÿ‰ kubectl top nodes # ์ƒ์„ธ ๋ฆฌ์†Œ์Šค ์ •๋ณด kubectl -n site11-pipeline describe pod ``` ### ๋ฌธ์ œ ํ•ด๊ฒฐ (K8s) #### Pod๊ฐ€ ์‹œ์ž‘๋˜์ง€ ์•Š์„ ๋•Œ ```bash # Pod ์ƒํƒœ ํ™•์ธ kubectl -n site11-pipeline describe pod # ์ด๋ฒคํŠธ ํ™•์ธ kubectl -n site11-pipeline get events --sort-by='.lastTimestamp' # ์ด๋ฏธ์ง€ ํ’€ ๋ฌธ์ œ ํ™•์ธ kubectl -n site11-pipeline get pods -o jsonpath='{.items[*].spec.containers[*].image}' ``` #### Redis/MongoDB ์—ฐ๊ฒฐ ์‹คํŒจ ```bash # Docker ํ˜ธ์ŠคํŠธ ๋„คํŠธ์›Œํฌ ํ™•์ธ # K8s Pod๋Š” host.docker.internal ์‚ฌ์šฉ kubectl -n site11-pipeline exec -it -- ping host.docker.internal # ์—ฐ๊ฒฐ ํ…Œ์ŠคํŠธ kubectl -n site11-pipeline exec -it -- redis-cli -h host.docker.internal ping ``` #### ์ „์ฒด ์ •๋ฆฌ ```bash # K8s ๋ฆฌ์†Œ์Šค ์‚ญ์ œ kubectl delete namespace site11-pipeline # Docker ์ •๋ฆฌ docker-compose -f docker-compose-hybrid.yml down # ๋ณผ๋ฅจ ์ •๋ฆฌ (์ฃผ์˜!) docker-compose -f docker-compose-hybrid.yml down -v ``` ## ๋ผ์ด์„ ์Šค (License) Copyright (c) 2024 Site11 Project. All rights reserved.