release
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# deployment/container/Dockerfile
|
||||
# Restaurant Collection Service Image
|
||||
ARG BASE_IMAGE=restaurant-api-base:latest
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# 메타데이터
|
||||
LABEL maintainer="admin@example.com"
|
||||
LABEL version="1.0.0"
|
||||
LABEL description="카카오 API 기반 음식점 수집 서비스"
|
||||
|
||||
# root로 전환 (패키지 설치용)
|
||||
USER root
|
||||
|
||||
# 환경 변수 설정
|
||||
ENV HOME=/home/appuser \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Python 의존성 파일 복사 및 설치
|
||||
COPY app/requirements.txt /app/
|
||||
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
# 애플리케이션 소스 복사
|
||||
COPY app/main.py /app/
|
||||
|
||||
# 데이터 디렉토리 생성 및 권한 설정
|
||||
RUN mkdir -p /app/data \
|
||||
&& chown -R appuser:appuser /app \
|
||||
&& chmod -R 755 /app
|
||||
|
||||
# 비root 사용자로 전환
|
||||
USER appuser
|
||||
|
||||
# 작업 디렉토리 설정
|
||||
WORKDIR /app
|
||||
|
||||
# 포트 노출
|
||||
EXPOSE 18000
|
||||
|
||||
# 헬스체크
|
||||
HEALTHCHECK --interval=30s --timeout=15s --start-period=30s --retries=3 \
|
||||
CMD curl -f http://localhost:18000/health || exit 1
|
||||
|
||||
# 애플리케이션 실행
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "18000", "--log-level", "info"]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# deployment/container/Dockerfile-base
|
||||
FROM python:3.11-slim
|
||||
|
||||
# 메타데이터
|
||||
LABEL maintainer="admin@example.com"
|
||||
LABEL description="카카오 API 기반 음식점 수집 서비스 - Base Image"
|
||||
LABEL version="base-1.0.0"
|
||||
|
||||
# 환경 변수 설정
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# 필수 패키지 설치
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
wget \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 비root 사용자 생성
|
||||
RUN groupadd -r appuser && useradd -r -g appuser -d /home/appuser -s /bin/bash appuser \
|
||||
&& mkdir -p /home/appuser \
|
||||
&& chown -R appuser:appuser /home/appuser
|
||||
|
||||
# 작업 디렉토리 생성
|
||||
WORKDIR /app
|
||||
RUN chown appuser:appuser /app
|
||||
|
||||
# pip 업그레이드
|
||||
RUN pip install --no-cache-dir --upgrade pip
|
||||
|
||||
# 포트 노출
|
||||
EXPOSE 8000
|
||||
|
||||
# 기본 명령어 (오버라이드 가능)
|
||||
CMD ["python", "--version"]
|
||||
@@ -0,0 +1,34 @@
|
||||
# deployment/manifests/configmap.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: restaurant-api-config
|
||||
data:
|
||||
# 애플리케이션 설정
|
||||
APP_TITLE: "카카오 API 기반 음식점 수집 서비스"
|
||||
APP_VERSION: "1.0.0"
|
||||
APP_DESCRIPTION: "카카오 로컬 API를 활용한 음식점 정보 수집 시스템"
|
||||
|
||||
# 서버 설정
|
||||
HOST: "0.0.0.0"
|
||||
PORT: "18000"
|
||||
LOG_LEVEL: "info"
|
||||
|
||||
# 카카오 API 설정
|
||||
KAKAO_API_URL: "https://dapi.kakao.com/v2/local/search/keyword.json"
|
||||
|
||||
# 검색 기본값
|
||||
DEFAULT_QUERY: "음식점"
|
||||
DEFAULT_REGION: "서울"
|
||||
DEFAULT_SIZE: "15"
|
||||
MAX_SIZE: "15"
|
||||
MAX_PAGES: "45"
|
||||
|
||||
# 파일 설정
|
||||
OUTPUT_FILE: "restaurant.json"
|
||||
DATA_DIR: "/app/data"
|
||||
|
||||
# 요청 제한 설정
|
||||
REQUEST_DELAY: "0.1"
|
||||
REQUEST_TIMEOUT: "30"
|
||||
HEALTH_CHECK_TIMEOUT: "10"
|
||||
@@ -0,0 +1,81 @@
|
||||
# deployment/manifests/deployment.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: restaurant-api
|
||||
labels:
|
||||
app: restaurant-api
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: restaurant-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: restaurant-api
|
||||
version: v1
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: acr-secret
|
||||
containers:
|
||||
- name: api
|
||||
image: acrdigitalgarage03.azurecr.io/restaurant-api:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 18000
|
||||
name: http
|
||||
|
||||
# ConfigMap 환경 변수
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: restaurant-api-config
|
||||
|
||||
# Secret 환경 변수
|
||||
env:
|
||||
- name: KAKAO_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: restaurant-api-secret
|
||||
key: KAKAO_API_KEY
|
||||
|
||||
# 리소스 제한
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "1Gi"
|
||||
cpu: "500m"
|
||||
|
||||
# 헬스 체크
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 18000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 18000
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
# 볼륨 마운트 (데이터 저장용)
|
||||
volumeMounts:
|
||||
- name: data-volume
|
||||
mountPath: /app/data
|
||||
|
||||
# 볼륨 정의
|
||||
volumes:
|
||||
- name: data-volume
|
||||
emptyDir: {}
|
||||
|
||||
restartPolicy: Always
|
||||
@@ -0,0 +1,38 @@
|
||||
# deployment/manifests/ingress.yaml
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: restaurant-api-ingress
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "false"
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
||||
# 타임아웃 설정 (API 수집 시간 고려)
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
|
||||
nginx.ingress.kubernetes.io/client-body-timeout: "300"
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
|
||||
# CORS 설정
|
||||
nginx.ingress.kubernetes.io/enable-cors: "true"
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, OPTIONS"
|
||||
nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
# 환경에 맞게 호스트명 수정 필요
|
||||
- host: restaurant-api.20.249.191.180.nip.io
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: restaurant-api-service
|
||||
port:
|
||||
number: 80
|
||||
# TLS 설정 (HTTPS 필요시 주석 해제)
|
||||
# tls:
|
||||
# - hosts:
|
||||
# - restaurant-api.example.com
|
||||
# secretName: restaurant-api-tls
|
||||
@@ -0,0 +1,10 @@
|
||||
# deployment/manifests/secret.yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: restaurant-api-secret
|
||||
type: Opaque
|
||||
data:
|
||||
# 카카오 API 키 (Base64 인코딩 필요)
|
||||
# echo -n "5cdc24407edbf8544f3954cfaa4650c6" | base64
|
||||
KAKAO_API_KEY: NWNkYzI0NDA3ZWRiZjg1NDRmMzk1NGNmYWE0NjUwYzY=
|
||||
@@ -0,0 +1,16 @@
|
||||
# deployment/manifests/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: restaurant-api-service
|
||||
labels:
|
||||
app: restaurant-api
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 18000
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: restaurant-api
|
||||
Reference in New Issue
Block a user