feat: Add hybrid deployment with Docker and Kubernetes
- Docker Compose for infrastructure (MongoDB, Redis, Kafka, Zookeeper) - Docker for central control (Scheduler, Monitor, Language Sync) - K8s for scalable workers (RSS, Google Search, Translator, AI Generator, Image Generator) - Automatic scaling with HPA (Horizontal Pod Autoscaler) - Comprehensive deployment scripts and documentation - Updated README with hybrid deployment guide
This commit is contained in:
147
README.md
147
README.md
@ -458,6 +458,153 @@ tar -czf config-backup.tar.gz .env docker-compose.yml services/
|
||||
- `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
|
||||
- **관리 콘솔**: Console Backend/Frontend
|
||||
|
||||
#### Kubernetes (무상태 워커)
|
||||
- **데이터 수집**: 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. K8s 워커 배포
|
||||
```bash
|
||||
# K8s 매니페스트 디렉토리로 이동
|
||||
cd k8s/pipeline
|
||||
|
||||
# API 키 설정 (configmap.yaml 편집)
|
||||
vim configmap.yaml
|
||||
|
||||
# 배포 실행
|
||||
./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 <pod-name>
|
||||
```
|
||||
|
||||
### 문제 해결 (K8s)
|
||||
|
||||
#### Pod가 시작되지 않을 때
|
||||
```bash
|
||||
# Pod 상태 확인
|
||||
kubectl -n site11-pipeline describe pod <pod-name>
|
||||
|
||||
# 이벤트 확인
|
||||
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 <pod-name> -- ping host.docker.internal
|
||||
|
||||
# 연결 테스트
|
||||
kubectl -n site11-pipeline exec -it <pod-name> -- 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.
|
||||
Reference in New Issue
Block a user