Jenkins 기반 CI/CD 파이프라인 구성

- Kustomize 기반 환경별(dev/staging/prod) 매니페스트 관리
- Jenkins 파이프라인 스크립트 작성 (Podman, Gradle, kubectl 컨테이너)
- SonarQube 코드 품질 분석 및 Quality Gate 연동
- 수동 배포 및 리소스 검증 스크립트 추가
- k8s 매니페스트 구조 재정리 (configmaps, secrets, deployments, services 분리)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ondal
2025-12-01 10:23:32 +09:00
parent 21b9c77109
commit f12fed5de9
113 changed files with 2955 additions and 3567 deletions
@@ -1,10 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-api-gateway
data:
SERVER_PORT: "8080"
BILL_SERVICE_URL: "http://bill-service"
PRODUCT_SERVICE_URL: "http://product-service"
USER_SERVICE_URL: "http://user-service"
KOS_MOCK_URL: "http://kos-mock"
@@ -1,21 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-bill-service
data:
SERVER_PORT: "8082"
DB_KIND: "postgresql"
DB_PORT: "5432"
DB_CONNECTION_TIMEOUT: "30000"
DB_IDLE_TIMEOUT: "600000"
DB_LEAK_DETECTION: "60000"
DB_MAX_LIFETIME: "1800000"
DB_MAX_POOL: "20"
DB_MIN_IDLE: "5"
KOS_BASE_URL: "http://kos-mock"
REDIS_DATABASE: "1"
REDIS_MAX_ACTIVE: "8"
REDIS_MAX_IDLE: "8"
REDIS_MAX_WAIT: "-1"
REDIS_MIN_IDLE: "0"
REDIS_TIMEOUT: "2000"
@@ -1,10 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-bill-service
type: Opaque
stringData:
DB_HOST: "bill-inquiry-postgres-dev-postgresql"
DB_NAME: "bill_inquiry_db"
DB_USERNAME: "bill_inquiry_user"
DB_PASSWORD: "BillUser2025@"
-11
View File
@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: bill-service
spec:
selector:
app: bill-service
ports:
- port: 80
targetPort: 8082
type: ClusterIP
-11
View File
@@ -1,11 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-common
data:
CORS_ALLOWED_ORIGINS: "http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://phonebill-dg0500.20.214.196.128.nip.io"
JWT_ACCESS_TOKEN_VALIDITY: "18000000"
JWT_REFRESH_TOKEN_VALIDITY: "86400000"
REDIS_PORT: "6379"
SPRING_PROFILES_ACTIVE: "dev"
DDL_AUTO: "update"
-49
View File
@@ -1,49 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: phonebill
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
ingressClassName: nginx
rules:
- host: phonebill-dg0500-api.20.214.196.128.nip.io
http:
paths:
- path: /api/v1/auth
pathType: Prefix
backend:
service:
name: user-service
port:
number: 80
- path: /api/v1/users
pathType: Prefix
backend:
service:
name: user-service
port:
number: 80
- path: /api/v1/bills
pathType: Prefix
backend:
service:
name: bill-service
port:
number: 80
- path: /api/v1/products
pathType: Prefix
backend:
service:
name: product-service
port:
number: 80
- path: /api/v1/kos
pathType: Prefix
backend:
service:
name: kos-mock
port:
number: 80
-9
View File
@@ -1,9 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-common
type: Opaque
stringData:
JWT_SECRET: "nwe5Yo9qaJ6FBD/Thl2/j6/SFAfNwUorAY1ZcWO2KI7uA4bmVLOCPxE9hYuUpRCOkgV2UF2DdHXtqHi3+BU/ecbz2zpHyf/720h48UbA3XOMYOX1sdM+dQ=="
REDIS_HOST: "redis-cache-dev-master"
REDIS_PASSWORD: "Redis2025Dev@"
@@ -1,16 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: phonebill
type: kubernetes.io/dockerconfigjson
stringData:
.dockerconfigjson: |
{
"auths": {
"acrdigitalgarage01.azurecr.io": {
"username": "acrdigitalgarage01",
"password": "+OY+rmOagorjWvQe/tTk6oqvnZI8SmNbY/Y2o5EDcY+ACRDCDbYk",
"auth": "YWNyZGlnaXRhbGdhcmFnZTAxOitPWStybU9hZ29yald2UWUvdFRrNm9xdm5aSThTbU5iWS9ZMm81RURjWStBQ1JEQ0RiWWs="
}
}
}
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: api-gateway-config
namespace: phonebill
labels:
app: api-gateway
app.kubernetes.io/part-of: phonebill
data:
SERVER_PORT: "8080"
USER_SERVICE_URL: "http://user-service:8081"
BILL_SERVICE_URL: "http://bill-service:8082"
PRODUCT_SERVICE_URL: "http://product-service:8083"
KOS_MOCK_URL: "http://kos-mock:8084"
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: bill-service-config
namespace: phonebill
labels:
app: bill-service
app.kubernetes.io/part-of: phonebill
data:
SERVER_PORT: "8082"
DB_HOST: "inquiry-postgresql"
DB_PORT: "5432"
DB_NAME: "inquirydb"
REDIS_DATABASE: "1"
KOS_BASE_URL: "http://kos-mock:8084"
DDL_AUTO: "update"
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: phonebill-common-config
namespace: phonebill
labels:
app.kubernetes.io/part-of: phonebill
data:
SPRING_PROFILES_ACTIVE: "prod"
REDIS_HOST: "cache-redis-master"
REDIS_PORT: "6379"
CORS_ALLOWED_ORIGINS: "http://localhost:3000,http://phonebill.72.155.72.236.nip.io"
SHOW_SQL: "false"
DDL_AUTO: "none"
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kos-mock-config
namespace: phonebill
labels:
app: kos-mock
app.kubernetes.io/part-of: phonebill
data:
SERVER_PORT: "8084"
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: product-service-config
namespace: phonebill
labels:
app: product-service
app.kubernetes.io/part-of: phonebill
data:
SERVER_PORT: "8083"
DB_HOST: "change-postgresql"
DB_PORT: "5432"
DB_NAME: "changedb"
REDIS_DATABASE: "2"
KOS_BASE_URL: "http://kos-mock:8084"
DDL_AUTO: "update"
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: user-service-config
namespace: phonebill
labels:
app: user-service
app.kubernetes.io/part-of: phonebill
data:
SERVER_PORT: "8081"
DB_HOST: "auth-postgresql"
DB_PORT: "5432"
DB_NAME: "authdb"
REDIS_DATABASE: "0"
DDL_AUTO: "update"
+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
# Minikube 백엔드 서비스 삭제 스크립트
# 작성자: 최운영(데옵스)
# 작성일: 2025-11-29
set -e
NAMESPACE=phonebill
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "=============================================="
echo " PhoneBill Backend - 리소스 삭제"
echo "=============================================="
echo ""
read -p "⚠️ $NAMESPACE 네임스페이스의 모든 리소스를 삭제하시겠습니까? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "삭제를 취소합니다."
exit 0
fi
echo ""
echo "[1/5] Ingress 삭제..."
kubectl delete -f "$SCRIPT_DIR/ingress/" --ignore-not-found=true || true
echo ""
echo "[2/5] Services 삭제..."
kubectl delete -f "$SCRIPT_DIR/services/" --ignore-not-found=true || true
echo ""
echo "[3/5] Deployments 삭제..."
kubectl delete -f "$SCRIPT_DIR/deployments/" --ignore-not-found=true || true
echo ""
echo "[4/5] ConfigMaps 삭제..."
kubectl delete -f "$SCRIPT_DIR/configmaps/" --ignore-not-found=true || true
echo ""
echo "[5/5] Secrets 삭제..."
kubectl delete -f "$SCRIPT_DIR/secrets/" --ignore-not-found=true || true
echo ""
echo "=============================================="
echo " 삭제 완료!"
echo "=============================================="
echo ""
echo "📦 남은 리소스 확인:"
kubectl get all -n $NAMESPACE 2>/dev/null || echo "리소스 없음"
echo ""
+103
View File
@@ -0,0 +1,103 @@
#!/bin/bash
# Minikube 백엔드 서비스 원클릭 배포 스크립트
# 작성자: 최운영(데옵스)
# 작성일: 2025-11-29
set -e
NAMESPACE=phonebill
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "=============================================="
echo " PhoneBill Backend - Minikube 배포 시작"
echo "=============================================="
# 1. Kubernetes Context 확인
echo ""
echo "[1/7] Kubernetes Context 확인..."
CURRENT_CONTEXT=$(kubectl config current-context)
echo "현재 Context: $CURRENT_CONTEXT"
if [[ "$CURRENT_CONTEXT" != "minikube-remote" ]]; then
echo "⚠️ 경고: 현재 Context가 minikube-remote가 아닙니다."
read -p "계속 진행하시겠습니까? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "배포를 취소합니다."
exit 1
fi
fi
# 2. Namespace 생성
echo ""
echo "[2/7] Namespace 생성..."
kubectl create namespace $NAMESPACE --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=$NAMESPACE
# 3. Secrets 적용
echo ""
echo "[3/7] Secrets 적용..."
kubectl apply -f "$SCRIPT_DIR/secrets/"
# 4. ConfigMaps 적용
echo ""
echo "[4/7] ConfigMaps 적용..."
kubectl apply -f "$SCRIPT_DIR/configmaps/"
# 5. Deployments 적용
echo ""
echo "[5/7] Deployments 적용..."
kubectl apply -f "$SCRIPT_DIR/deployments/"
# 6. Services 적용
echo ""
echo "[6/7] Services 적용..."
kubectl apply -f "$SCRIPT_DIR/services/"
# 7. Ingress 적용
echo ""
echo "[7/7] Ingress 적용..."
kubectl apply -f "$SCRIPT_DIR/ingress/"
# 배포 상태 대기
echo ""
echo "=============================================="
echo " 배포 상태 확인 중..."
echo "=============================================="
for service in api-gateway user-service bill-service product-service kos-mock; do
echo ""
echo "$service 배포 대기 중..."
kubectl rollout status deployment/$service -n $NAMESPACE --timeout=180s || {
echo "$service 배포 실패"
kubectl describe deployment/$service -n $NAMESPACE
exit 1
}
echo "$service 배포 완료"
done
# 최종 상태 출력
echo ""
echo "=============================================="
echo " 배포 완료!"
echo "=============================================="
echo ""
echo "📦 Pods 상태:"
kubectl get pods -n $NAMESPACE
echo ""
echo "🔗 Services:"
kubectl get svc -n $NAMESPACE
echo ""
echo "🌐 Ingress:"
kubectl get ingress -n $NAMESPACE
echo ""
echo "=============================================="
echo " 접속 방법"
echo "=============================================="
echo ""
echo "API Gateway Ingress Host:"
echo " phonebill-api.72.155.72.236.nip.io"
echo ""
echo "Health Check:"
echo " curl http://phonebill-api.72.155.72.236.nip.io/actuator/health"
echo ""
-313
View File
@@ -1,313 +0,0 @@
# 통신요금 관리 서비스 백엔드 Kubernetes 배포 가이드
## 📋 배포 개요
**시스템명**: phonebill
**네임스페이스**: phonebill-dev
**ACR명**: acrdigitalgarage01
**k8s명**: aks-digitalgarage-01
**파드수**: 1개 (각 서비스)
**리소스**: CPU 256m/1024m, 메모리 256Mi/1024Mi
## 🎯 배포 대상 서비스
| 서비스명 | 포트 | 엔드포인트 |
|---------|------|-----------|
| api-gateway | 8080 | Gateway 및 라우팅 |
| user-service | 8081 | /api/v1/auth, /api/v1/users |
| bill-service | 8082 | /api/v1/bills |
| product-service | 8083 | /api/v1/products |
| kos-mock | 8084 | /api/v1/kos |
## 📋 배포 전 검증 결과
### ✅ 검증 완료 항목
- 객체이름 네이밍룰 준수
- Secret에서 stringData 사용
- JWT_SECRET 실행 프로파일 값 적용
- Image 경로 올바른 형식
- Service/Ingress 포트 매핑 일치 (80번)
- Controller @RequestMapping 기반 path 설정
- 보안 환경변수 Secret 분리
- REDIS_DATABASE 서비스별 구분 (0,1,2)
- envFrom 사용으로 환경변수 주입
- 실행 프로파일 전체 환경변수 매핑 완료
### ✅ 배포 전 확인 완료 사항
모든 환경 정보가 확인되어 매니페스트 파일에 반영 완료되었습니다:
1. **✅ Ingress Controller External IP**: `20.214.196.128`
2. **✅ ACR 인증 정보**: `acrdigitalgarage01` / 실제 패스워드 적용
3. **✅ Redis Service**: `redis-cache-dev-master`
4. **✅ Database Services**:
- User Service: `auth-postgres-dev-postgresql`
- Bill Service: `bill-inquiry-postgres-dev-postgresql`
- Product Service: `product-change-postgres-dev-postgresql`
## 🔧 사전 확인 방법
### 1. Azure 로그인 상태 확인
```bash
az account show
```
### 2. AKS Credential 확인
```bash
kubectl cluster-info
```
### 3. 네임스페이스 존재 확인
```bash
kubectl get ns phonebill-dev
```
### 4. Ingress Controller External IP 확인 ✅
```bash
kubectl get svc ingress-nginx-controller -n ingress-nginx
```
**확인 완료**: EXTERNAL-IP = `20.214.196.128`
### 5. ACR 인증 정보 확인 ✅
```bash
# USERNAME 확인
USERNAME=$(az acr credential show -n acrdigitalgarage01 --query "username" -o tsv)
echo $USERNAME
# PASSWORD 확인
PASSWORD=$(az acr credential show -n acrdigitalgarage01 --query "passwords[0].value" -o tsv)
echo $PASSWORD
```
**확인 완료**: USERNAME = `acrdigitalgarage01`, PASSWORD = 실제 값 적용
### 6. Redis Service 이름 확인 ✅
```bash
kubectl get svc -n phonebill-dev | grep redis
```
**확인 완료**: `redis-cache-dev-master` (ClusterIP)
### 7. Database Service 이름 확인 ✅
```bash
# 각 서비스별 DB 확인
kubectl get svc -n phonebill-dev | grep auth
kubectl get svc -n phonebill-dev | grep bill
kubectl get svc -n phonebill-dev | grep product
```
**확인 완료**:
- User Service: `auth-postgres-dev-postgresql`
- Bill Service: `bill-inquiry-postgres-dev-postgresql`
- Product Service: `product-change-postgres-dev-postgresql`
## ✅ 매니페스트 업데이트 완료
모든 매니페스트 파일이 실제 환경 정보로 업데이트 완료되었습니다:
### 1. ✅ Ingress External IP 적용
`deployment/k8s/common/ingress.yaml`:
```yaml
host: phonebill-api.20.214.196.128.nip.io
```
### 2. ✅ CORS Origins 적용
`deployment/k8s/common/cm-common.yaml`:
```yaml
CORS_ALLOWED_ORIGINS: "http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://phonebill.20.214.196.128.nip.io"
```
### 3. ✅ ACR 인증 정보 적용
`deployment/k8s/common/secret-imagepull.yaml`:
```yaml
stringData:
.dockerconfigjson: |
{
"auths": {
"acrdigitalgarage01.azurecr.io": {
"username": "acrdigitalgarage01",
"password": "+OY+rmOagorjWvQe/tTk6oqvnZI8SmNbY/Y2o5EDcY+ACRDCDbYk",
"auth": "YWNyZGlnaXRhbGdhcmFnZTAxOitPWStybU9hZ29yald2UWUvdFRrNm9xdm5aSThTbU5iWS9ZMm81RURjWStBQ1JEQ0RiWWs="
}
}
}
```
### 4. ✅ Redis Host 적용
`deployment/k8s/common/secret-common.yaml`:
```yaml
REDIS_HOST: "redis-cache-dev-master"
```
### 5. ✅ Database Host 적용
**user-service**: `deployment/k8s/user-service/secret-user-service.yaml`
```yaml
DB_HOST: "auth-postgres-dev-postgresql"
```
**bill-service**: `deployment/k8s/bill-service/secret-bill-service.yaml`
```yaml
DB_HOST: "bill-inquiry-postgres-dev-postgresql"
```
**product-service**: `deployment/k8s/product-service/secret-product-service.yaml`
```yaml
DB_HOST: "product-change-postgres-dev-postgresql"
```
## 🚀 배포 실행 가이드
### 1. 공통 매니페스트 적용
```bash
kubectl apply -f deployment/k8s/common/
```
### 2. 서비스별 매니페스트 적용
```bash
# 각 서비스 순차 적용
kubectl apply -f deployment/k8s/api-gateway/
kubectl apply -f deployment/k8s/user-service/
kubectl apply -f deployment/k8s/bill-service/
kubectl apply -f deployment/k8s/product-service/
kubectl apply -f deployment/k8s/kos-mock/
```
### 3. 배포 상태 확인
#### 전체 객체 확인
```bash
kubectl get all -n phonebill-dev
```
#### Pod 상태 확인
```bash
kubectl get pods -n phonebill-dev
```
#### Service 확인
```bash
kubectl get svc -n phonebill-dev
```
#### Ingress 확인
```bash
kubectl get ingress -n phonebill-dev
```
#### ConfigMap/Secret 확인
```bash
kubectl get cm,secret -n phonebill-dev
```
### 4. 로그 확인
```bash
# 특정 서비스 로그 확인
kubectl logs -f deployment/user-service -n phonebill-dev
kubectl logs -f deployment/bill-service -n phonebill-dev
kubectl logs -f deployment/product-service -n phonebill-dev
kubectl logs -f deployment/api-gateway -n phonebill-dev
kubectl logs -f deployment/kos-mock -n phonebill-dev
```
### 5. Health Check 확인
```bash
# 각 서비스 Health 상태 확인 (Pod 내부에서)
kubectl exec -n phonebill-dev deployment/user-service -- curl http://localhost:8081/actuator/health
kubectl exec -n phonebill-dev deployment/bill-service -- curl http://localhost:8082/actuator/health
kubectl exec -n phonebill-dev deployment/product-service -- curl http://localhost:8083/actuator/health
```
## 🔍 문제 해결 가이드
### Pod 시작 실패시
```bash
# Pod 상세 정보 확인
kubectl describe pod <POD_NAME> -n phonebill-dev
# 이벤트 확인
kubectl get events -n phonebill-dev --sort-by='.lastTimestamp'
```
### ConfigMap/Secret 변경시
```bash
# 변경 후 Pod 재시작
kubectl rollout restart deployment/<SERVICE_NAME> -n phonebill-dev
```
### 네트워크 연결 문제
```bash
# Service DNS 해결 테스트
kubectl exec -n phonebill-dev deployment/api-gateway -- nslookup user-service
```
## 📊 환경변수 매핑 테이블
| 서비스명 | 환경변수 | 지정 객체명 | 환경변수값 |
|---------|---------|-----------|-----------|
| api-gateway | SERVER_PORT | cm-api-gateway | 8080 |
| api-gateway | BILL_SERVICE_URL | cm-api-gateway | http://bill-service |
| api-gateway | PRODUCT_SERVICE_URL | cm-api-gateway | http://product-service |
| api-gateway | USER_SERVICE_URL | cm-api-gateway | http://user-service |
| api-gateway | KOS_MOCK_URL | cm-api-gateway | http://kos-mock |
| 공통 | CORS_ALLOWED_ORIGINS | cm-common | http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://phonebill.{EXTERNAL_IP}.nip.io |
| 공통 | JWT_ACCESS_TOKEN_VALIDITY | cm-common | 18000000 |
| 공통 | JWT_REFRESH_TOKEN_VALIDITY | cm-common | 86400000 |
| 공통 | JWT_SECRET | secret-common | (base64 encoded JWT secret) |
| 공통 | REDIS_HOST | secret-common | (Redis 서비스명) |
| 공통 | REDIS_PASSWORD | secret-common | Redis2025Dev! |
| 공통 | REDIS_PORT | cm-common | 6379 |
| 공통 | SPRING_PROFILES_ACTIVE | cm-common | dev |
| user-service | SERVER_PORT | cm-user-service | 8081 |
| user-service | DB_KIND | cm-user-service | postgresql |
| user-service | DB_PORT | cm-user-service | 5432 |
| user-service | DDL_AUTO | cm-user-service | update |
| user-service | REDIS_DATABASE | cm-user-service | 0 |
| user-service | SHOW_SQL | cm-user-service | true |
| user-service | DB_HOST | secret-user-service | (Auth DB 서비스명) |
| user-service | DB_NAME | secret-user-service | phonebill_auth |
| user-service | DB_USERNAME | secret-user-service | auth_user |
| user-service | DB_PASSWORD | secret-user-service | AuthUser2025! |
| bill-service | SERVER_PORT | cm-bill-service | 8082 |
| bill-service | DB_KIND | cm-bill-service | postgresql |
| bill-service | DB_PORT | cm-bill-service | 5432 |
| bill-service | DB_CONNECTION_TIMEOUT | cm-bill-service | 30000 |
| bill-service | DB_IDLE_TIMEOUT | cm-bill-service | 600000 |
| bill-service | DB_LEAK_DETECTION | cm-bill-service | 60000 |
| bill-service | DB_MAX_LIFETIME | cm-bill-service | 1800000 |
| bill-service | DB_MAX_POOL | cm-bill-service | 20 |
| bill-service | DB_MIN_IDLE | cm-bill-service | 5 |
| bill-service | KOS_BASE_URL | cm-bill-service | http://kos-mock |
| bill-service | LOG_FILE_NAME | cm-bill-service | logs/bill-service.log |
| bill-service | REDIS_DATABASE | cm-bill-service | 1 |
| bill-service | REDIS_MAX_ACTIVE | cm-bill-service | 8 |
| bill-service | REDIS_MAX_IDLE | cm-bill-service | 8 |
| bill-service | REDIS_MAX_WAIT | cm-bill-service | -1 |
| bill-service | REDIS_MIN_IDLE | cm-bill-service | 0 |
| bill-service | REDIS_TIMEOUT | cm-bill-service | 2000 |
| bill-service | DB_HOST | secret-bill-service | (Bill DB 서비스명) |
| bill-service | DB_NAME | secret-bill-service | bill_inquiry_db |
| bill-service | DB_USERNAME | secret-bill-service | bill_inquiry_user |
| bill-service | DB_PASSWORD | secret-bill-service | BillUser2025! |
| product-service | SERVER_PORT | cm-product-service | 8083 |
| product-service | DB_KIND | cm-product-service | postgresql |
| product-service | DB_PORT | cm-product-service | 5432 |
| product-service | DDL_AUTO | cm-product-service | update |
| product-service | KOS_BASE_URL | cm-product-service | http://kos-mock |
| product-service | KOS_CLIENT_ID | cm-product-service | product-service-dev |
| product-service | KOS_MOCK_ENABLED | cm-product-service | true |
| product-service | REDIS_DATABASE | cm-product-service | 2 |
| product-service | DB_HOST | secret-product-service | (Product DB 서비스명) |
| product-service | DB_NAME | secret-product-service | product_change_db |
| product-service | DB_USERNAME | secret-product-service | product_change_user |
| product-service | DB_PASSWORD | secret-product-service | ProductUser2025! |
| product-service | KOS_API_KEY | secret-product-service | dev-api-key |
| kos-mock | SERVER_PORT | cm-kos-mock | 8084 |
## 🎯 배포 완료 후 접근 URL
- **API Gateway**: http://phonebill-api.20.214.196.128.nip.io
- **Swagger UI**: http://phonebill-api.20.214.196.128.nip.io/swagger-ui/index.html
- **사용자 인증**: http://phonebill-api.20.214.196.128.nip.io/api/v1/auth
- **요금 조회**: http://phonebill-api.20.214.196.128.nip.io/api/v1/bills
- **상품 변경**: http://phonebill-api.20.214.196.128.nip.io/api/v1/products
---
**✅ 배포 준비 완료**: 모든 환경 정보가 확인되어 매니페스트 파일에 반영되었습니다. 이제 바로 배포를 진행할 수 있습니다.
+867
View File
@@ -0,0 +1,867 @@
# Minikube 백엔드 서비스 배포 가이드
## 개요
본 문서는 phonebill 프로젝트의 백엔드 마이크로서비스들을 Minikube 환경에 배포하는 방법을 설명합니다.
## 배포 대상 서비스
| 서비스명 | 포트 | 설명 |
|---------|------|------|
| api-gateway | 8080 | API Gateway 서비스 |
| user-service | 8081 | 사용자 인증/관리 서비스 |
| bill-service | 8082 | 요금 조회 서비스 |
| product-service | 8083 | 상품 변경 서비스 |
| kos-mock | 8084 | KOS 목업 서비스 |
## 배포 환경 정보
| 항목 | 값 |
|------|-----|
| Image Registry | docker.io |
| Image Organization | hiondal |
| Kubernetes Context | minikube-remote |
| Namespace | phonebill |
| Replicas | 1 |
| CPU Request/Limit | 256m/1024m |
| Memory Request/Limit | 256Mi/1024Mi |
---
## 사전 준비
### 1. Minikube 상태 확인
```bash
# context 전환
kubectl config use-context minikube-remote
# minikube 상태 확인
minikube status
# 노드 확인
kubectl get nodes
```
### 2. Namespace 생성
```bash
kubectl create namespace phonebill
kubectl config set-context --current --namespace=phonebill
```
### 3. Ingress Controller 활성화
```bash
minikube addons enable ingress
```
### 4. 백킹 서비스 확인
배포 전 PostgreSQL과 Redis가 실행 중인지 확인합니다:
```bash
# PostgreSQL 파드 확인
kubectl get pods -n phonebill | grep postgres
# Redis 파드 확인
kubectl get pods -n phonebill | grep redis
```
---
## Step 1: 컨테이너 이미지 빌드 및 푸시
### 1.1 Gradle 빌드
```bash
cd /Users/dreamondal/home/workspace/phonebill
./gradlew clean build -x test
```
### 1.2 Docker 이미지 빌드
```bash
DOCKER_FILE=deployment/container/Dockerfile-backend
REGISTRY=docker.io
PROJECT=hiondal
TAG=latest
# 각 서비스 이미지 빌드
for service in api-gateway user-service bill-service product-service kos-mock; do
docker build \
--platform linux/amd64 \
--build-arg BUILD_LIB_DIR="${service}/build/libs" \
--build-arg ARTIFACTORY_FILE="${service}.jar" \
-f ${DOCKER_FILE} \
-t ${REGISTRY}/${PROJECT}/${service}:${TAG} .
done
```
### 1.3 Docker Hub 푸시
```bash
# Docker Hub 로그인
docker login
# 이미지 푸시
for service in api-gateway user-service bill-service product-service kos-mock; do
docker push ${REGISTRY}/${PROJECT}/${service}:${TAG}
done
```
---
## Step 2: Secret 생성
### 2.1 공통 Secret (JWT, Redis)
```bash
kubectl create secret generic phonebill-common-secret \
--namespace=phonebill \
--from-literal=JWT_SECRET='your-jwt-secret-key-must-be-at-least-256-bits-long-for-hs256' \
--from-literal=REDIS_PASSWORD=''
```
### 2.2 서비스별 DB Secret
```bash
# user-service DB Secret
kubectl create secret generic user-service-db-secret \
--namespace=phonebill \
--from-literal=DB_USERNAME='postgres' \
--from-literal=DB_PASSWORD='your-auth-db-password'
# bill-service DB Secret
kubectl create secret generic bill-service-db-secret \
--namespace=phonebill \
--from-literal=DB_USERNAME='postgres' \
--from-literal=DB_PASSWORD='your-bill-db-password'
# product-service DB Secret
kubectl create secret generic product-service-db-secret \
--namespace=phonebill \
--from-literal=DB_USERNAME='postgres' \
--from-literal=DB_PASSWORD='your-product-db-password'
```
---
## Step 3: ConfigMap 생성
### 3.1 공통 ConfigMap
```bash
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: phonebill-common-config
namespace: phonebill
data:
SPRING_PROFILES_ACTIVE: "prod"
REDIS_HOST: "redis-cache.phonebill.svc.cluster.local"
REDIS_PORT: "6379"
CORS_ALLOWED_ORIGINS: "*"
SHOW_SQL: "false"
DDL_AUTO: "none"
EOF
```
### 3.2 서비스별 ConfigMap
```bash
# API Gateway ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: api-gateway-config
namespace: phonebill
data:
SERVER_PORT: "8080"
USER_SERVICE_URL: "http://user-service:8081"
BILL_SERVICE_URL: "http://bill-service:8082"
PRODUCT_SERVICE_URL: "http://product-service:8083"
KOS_MOCK_URL: "http://kos-mock:8084"
EOF
# User Service ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: user-service-config
namespace: phonebill
data:
SERVER_PORT: "8081"
DB_HOST: "auth-postgres.phonebill.svc.cluster.local"
DB_PORT: "5432"
DB_NAME: "phonebill_auth"
REDIS_DATABASE: "0"
EOF
# Bill Service ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: bill-service-config
namespace: phonebill
data:
SERVER_PORT: "8082"
DB_HOST: "bill-inquiry-postgres.phonebill.svc.cluster.local"
DB_PORT: "5432"
DB_NAME: "bill_inquiry"
REDIS_DATABASE: "1"
KOS_BASE_URL: "http://kos-mock:8084"
EOF
# Product Service ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: product-service-config
namespace: phonebill
data:
SERVER_PORT: "8083"
DB_HOST: "product-change-postgres.phonebill.svc.cluster.local"
DB_PORT: "5432"
DB_NAME: "product_change"
REDIS_DATABASE: "2"
KOS_BASE_URL: "http://kos-mock:8084"
EOF
# KOS Mock ConfigMap
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: kos-mock-config
namespace: phonebill
data:
SERVER_PORT: "8084"
EOF
```
---
## Step 4: Deployment 생성
### 4.1 API Gateway Deployment
```bash
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
namespace: phonebill
labels:
app: api-gateway
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: docker.io/hiondal/api-gateway:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: phonebill-common-config
- configMapRef:
name: api-gateway-config
- secretRef:
name: phonebill-common-secret
resources:
requests:
cpu: "256m"
memory: "256Mi"
limits:
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
EOF
```
### 4.2 User Service Deployment
```bash
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-service
namespace: phonebill
labels:
app: user-service
spec:
replicas: 1
selector:
matchLabels:
app: user-service
template:
metadata:
labels:
app: user-service
spec:
containers:
- name: user-service
image: docker.io/hiondal/user-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8081
envFrom:
- configMapRef:
name: phonebill-common-config
- configMapRef:
name: user-service-config
- secretRef:
name: phonebill-common-secret
- secretRef:
name: user-service-db-secret
resources:
requests:
cpu: "256m"
memory: "256Mi"
limits:
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8081
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8081
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
EOF
```
### 4.3 Bill Service Deployment
```bash
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: bill-service
namespace: phonebill
labels:
app: bill-service
spec:
replicas: 1
selector:
matchLabels:
app: bill-service
template:
metadata:
labels:
app: bill-service
spec:
containers:
- name: bill-service
image: docker.io/hiondal/bill-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8082
envFrom:
- configMapRef:
name: phonebill-common-config
- configMapRef:
name: bill-service-config
- secretRef:
name: phonebill-common-secret
- secretRef:
name: bill-service-db-secret
resources:
requests:
cpu: "256m"
memory: "256Mi"
limits:
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8082
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8082
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
EOF
```
### 4.4 Product Service Deployment
```bash
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: product-service
namespace: phonebill
labels:
app: product-service
spec:
replicas: 1
selector:
matchLabels:
app: product-service
template:
metadata:
labels:
app: product-service
spec:
containers:
- name: product-service
image: docker.io/hiondal/product-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8083
envFrom:
- configMapRef:
name: phonebill-common-config
- configMapRef:
name: product-service-config
- secretRef:
name: phonebill-common-secret
- secretRef:
name: product-service-db-secret
resources:
requests:
cpu: "256m"
memory: "256Mi"
limits:
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8083
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8083
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
EOF
```
### 4.5 KOS Mock Deployment
```bash
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: kos-mock
namespace: phonebill
labels:
app: kos-mock
spec:
replicas: 1
selector:
matchLabels:
app: kos-mock
template:
metadata:
labels:
app: kos-mock
spec:
containers:
- name: kos-mock
image: docker.io/hiondal/kos-mock:latest
imagePullPolicy: Always
ports:
- containerPort: 8084
envFrom:
- configMapRef:
name: phonebill-common-config
- configMapRef:
name: kos-mock-config
- secretRef:
name: phonebill-common-secret
resources:
requests:
cpu: "256m"
memory: "256Mi"
limits:
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8084
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8084
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
EOF
```
---
## Step 5: Service 생성
```bash
# API Gateway Service
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: api-gateway
namespace: phonebill
spec:
type: ClusterIP
selector:
app: api-gateway
ports:
- port: 8080
targetPort: 8080
protocol: TCP
EOF
# User Service
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: user-service
namespace: phonebill
spec:
type: ClusterIP
selector:
app: user-service
ports:
- port: 8081
targetPort: 8081
protocol: TCP
EOF
# Bill Service
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: bill-service
namespace: phonebill
spec:
type: ClusterIP
selector:
app: bill-service
ports:
- port: 8082
targetPort: 8082
protocol: TCP
EOF
# Product Service
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: product-service
namespace: phonebill
spec:
type: ClusterIP
selector:
app: product-service
ports:
- port: 8083
targetPort: 8083
protocol: TCP
EOF
# KOS Mock Service
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: kos-mock
namespace: phonebill
spec:
type: ClusterIP
selector:
app: kos-mock
ports:
- port: 8084
targetPort: 8084
protocol: TCP
EOF
```
---
## Step 6: Ingress 생성
```bash
kubectl apply -f - <<EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: phonebill-ingress
namespace: phonebill
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /\$1
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
spec:
ingressClassName: nginx
rules:
- host: phonebill-api.72.155.72.236.nip.io
http:
paths:
- path: /(.*)
pathType: ImplementationSpecific
backend:
service:
name: api-gateway
port:
number: 8080
EOF
```
> **참고**: nip.io 도메인을 사용하므로 별도의 hosts 파일 설정이 필요하지 않습니다.
---
## Step 7: 배포 확인
### 7.1 파드 상태 확인
```bash
kubectl get pods -n phonebill -w
```
### 7.2 로그 확인
```bash
# 각 서비스 로그 확인
kubectl logs -f deployment/api-gateway -n phonebill
kubectl logs -f deployment/user-service -n phonebill
kubectl logs -f deployment/bill-service -n phonebill
kubectl logs -f deployment/product-service -n phonebill
kubectl logs -f deployment/kos-mock -n phonebill
```
### 7.3 서비스 엔드포인트 확인
```bash
kubectl get endpoints -n phonebill
```
### 7.4 Ingress 상태 확인
```bash
kubectl get ingress -n phonebill
```
---
## Step 8: API 테스트
### 8.1 Health Check
```bash
# API Gateway Health Check
curl http://phonebill-api.72.155.72.236.nip.io/actuator/health
```
### 8.2 서비스 API 테스트
```bash
# 사용자 등록 API
curl -X POST http://phonebill-api.72.155.72.236.nip.io/api/users/register \
-H "Content-Type: application/json" \
-d '{
"userId": "testuser",
"password": "Test1234!",
"name": "테스트사용자",
"email": "test@example.com",
"phoneNumber": "01012345678"
}'
# 로그인 API
curl -X POST http://phonebill-api.72.155.72.236.nip.io/api/users/login \
-H "Content-Type: application/json" \
-d '{
"userId": "testuser",
"password": "Test1234!"
}'
```
---
## 트러블슈팅
### 파드가 시작되지 않는 경우
```bash
# 파드 상세 정보 확인
kubectl describe pod <pod-name> -n phonebill
# 이벤트 확인
kubectl get events -n phonebill --sort-by='.lastTimestamp'
```
### 이미지 풀 실패
```bash
# Docker Hub 인증 Secret 생성 (필요시)
kubectl create secret docker-registry regcred \
--namespace=phonebill \
--docker-server=https://index.docker.io/v1/ \
--docker-username=<username> \
--docker-password=<password> \
--docker-email=<email>
# Deployment에 imagePullSecrets 추가
kubectl patch deployment <deployment-name> -n phonebill \
-p '{"spec":{"template":{"spec":{"imagePullSecrets":[{"name":"regcred"}]}}}}'
```
### DB 연결 실패
```bash
# PostgreSQL 서비스 확인
kubectl get svc -n phonebill | grep postgres
# DNS 해석 테스트
kubectl run -it --rm debug --image=busybox --restart=Never -n phonebill \
-- nslookup auth-postgres.phonebill.svc.cluster.local
```
### Redis 연결 실패
```bash
# Redis 서비스 확인
kubectl get svc -n phonebill | grep redis
# Redis 연결 테스트
kubectl run -it --rm redis-cli --image=redis:alpine --restart=Never -n phonebill \
-- redis-cli -h redis-cache.phonebill.svc.cluster.local ping
```
---
## 리소스 정리
### 전체 삭제
```bash
kubectl delete namespace phonebill
```
### 개별 삭제
```bash
# Ingress 삭제
kubectl delete ingress phonebill-ingress -n phonebill
# 서비스 삭제
kubectl delete svc api-gateway user-service bill-service product-service kos-mock -n phonebill
# Deployment 삭제
kubectl delete deployment api-gateway user-service bill-service product-service kos-mock -n phonebill
# ConfigMap 삭제
kubectl delete configmap phonebill-common-config api-gateway-config user-service-config \
bill-service-config product-service-config kos-mock-config -n phonebill
# Secret 삭제
kubectl delete secret phonebill-common-secret user-service-db-secret \
bill-service-db-secret product-service-db-secret -n phonebill
```
---
## 원클릭 배포 스크립트
전체 배포를 한 번에 수행하는 스크립트:
```bash
#!/bin/bash
# deploy-all.sh
NAMESPACE=phonebill
REGISTRY=docker.io
PROJECT=hiondal
TAG=latest
echo "=== Minikube Backend 배포 시작 ==="
# 1. Namespace 생성
kubectl create namespace $NAMESPACE --dry-run=client -o yaml | kubectl apply -f -
# 2. Secrets 생성
echo "Creating secrets..."
kubectl create secret generic phonebill-common-secret \
--namespace=$NAMESPACE \
--from-literal=JWT_SECRET='your-jwt-secret-key-must-be-at-least-256-bits-long-for-hs256' \
--from-literal=REDIS_PASSWORD='' \
--dry-run=client -o yaml | kubectl apply -f -
# 3. ConfigMaps 적용
echo "Applying ConfigMaps..."
kubectl apply -f deployment/k8s/configmaps/
# 4. Deployments 적용
echo "Applying Deployments..."
kubectl apply -f deployment/k8s/deployments/
# 5. Services 적용
echo "Applying Services..."
kubectl apply -f deployment/k8s/services/
# 6. Ingress 적용
echo "Applying Ingress..."
kubectl apply -f deployment/k8s/ingress/
# 7. 배포 상태 확인
echo "Waiting for deployments..."
kubectl rollout status deployment/api-gateway -n $NAMESPACE --timeout=120s
kubectl rollout status deployment/user-service -n $NAMESPACE --timeout=120s
kubectl rollout status deployment/bill-service -n $NAMESPACE --timeout=120s
kubectl rollout status deployment/product-service -n $NAMESPACE --timeout=120s
kubectl rollout status deployment/kos-mock -n $NAMESPACE --timeout=120s
echo "=== 배포 완료 ==="
kubectl get pods -n $NAMESPACE
```
---
## 작성자
- **작성자**: 최운영(데옵스)
- **작성일**: 2025-11-29
- **버전**: 1.0.0
@@ -2,6 +2,10 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
namespace: phonebill
labels:
app: api-gateway
app.kubernetes.io/part-of: phonebill
spec:
replicas: 1
selector:
@@ -12,46 +16,40 @@ spec:
labels:
app: api-gateway
spec:
imagePullSecrets:
- name: phonebill
containers:
- name: api-gateway
image: acrdigitalgarage01.azurecr.io/phonebill/api-gateway:latest
image: docker.io/hiondal/api-gateway:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
name: http
envFrom:
- configMapRef:
name: cm-common
name: phonebill-common-config
- configMapRef:
name: cm-api-gateway
name: api-gateway-config
- secretRef:
name: secret-common
name: phonebill-common-secret
resources:
requests:
cpu: 256m
memory: 256Mi
cpu: "256m"
memory: "256Mi"
limits:
cpu: 1024m
memory: 1024Mi
startupProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 6
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /health
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 5
failureThreshold: 3
@@ -2,6 +2,10 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: bill-service
namespace: phonebill
labels:
app: bill-service
app.kubernetes.io/part-of: phonebill
spec:
replicas: 1
selector:
@@ -12,48 +16,42 @@ spec:
labels:
app: bill-service
spec:
imagePullSecrets:
- name: phonebill
containers:
- name: bill-service
image: acrdigitalgarage01.azurecr.io/phonebill/bill-service:latest
image: docker.io/hiondal/bill-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8082
name: http
envFrom:
- configMapRef:
name: cm-common
name: phonebill-common-config
- configMapRef:
name: cm-bill-service
name: bill-service-config
- secretRef:
name: secret-common
name: phonebill-common-secret
- secretRef:
name: secret-bill-service
name: bill-service-db-secret
resources:
requests:
cpu: 256m
memory: 256Mi
cpu: "256m"
memory: "256Mi"
limits:
cpu: 1024m
memory: 1024Mi
startupProbe:
httpGet:
path: /actuator/health
port: 8082
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 6
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8082
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8082
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8082
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 5
failureThreshold: 3
@@ -2,6 +2,10 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: kos-mock
namespace: phonebill
labels:
app: kos-mock
app.kubernetes.io/part-of: phonebill
spec:
replicas: 1
selector:
@@ -12,46 +16,40 @@ spec:
labels:
app: kos-mock
spec:
imagePullSecrets:
- name: phonebill
containers:
- name: kos-mock
image: acrdigitalgarage01.azurecr.io/phonebill/kos-mock:latest
image: docker.io/hiondal/kos-mock:latest
imagePullPolicy: Always
ports:
- containerPort: 8084
name: http
envFrom:
- configMapRef:
name: cm-common
name: phonebill-common-config
- configMapRef:
name: cm-kos-mock
name: kos-mock-config
- secretRef:
name: secret-common
name: phonebill-common-secret
resources:
requests:
cpu: 256m
memory: 256Mi
cpu: "256m"
memory: "256Mi"
limits:
cpu: 1024m
memory: 1024Mi
startupProbe:
httpGet:
path: /actuator/health
port: 8084
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 6
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8084
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8084
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8084
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 5
failureThreshold: 3
@@ -2,6 +2,10 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: product-service
namespace: phonebill
labels:
app: product-service
app.kubernetes.io/part-of: phonebill
spec:
replicas: 1
selector:
@@ -12,48 +16,42 @@ spec:
labels:
app: product-service
spec:
imagePullSecrets:
- name: phonebill
containers:
- name: product-service
image: acrdigitalgarage01.azurecr.io/phonebill/product-service:latest
image: docker.io/hiondal/product-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8083
name: http
envFrom:
- configMapRef:
name: cm-common
name: phonebill-common-config
- configMapRef:
name: cm-product-service
name: product-service-config
- secretRef:
name: secret-common
name: phonebill-common-secret
- secretRef:
name: secret-product-service
name: product-service-db-secret
resources:
requests:
cpu: 256m
memory: 256Mi
cpu: "256m"
memory: "256Mi"
limits:
cpu: 1024m
memory: 1024Mi
startupProbe:
httpGet:
path: /actuator/health
port: 8083
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 6
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8083
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8083
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8083
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 5
failureThreshold: 3
@@ -2,6 +2,10 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: user-service
namespace: phonebill
labels:
app: user-service
app.kubernetes.io/part-of: phonebill
spec:
replicas: 1
selector:
@@ -12,48 +16,42 @@ spec:
labels:
app: user-service
spec:
imagePullSecrets:
- name: phonebill
containers:
- name: user-service
image: acrdigitalgarage01.azurecr.io/phonebill/user-service:latest
image: docker.io/hiondal/user-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8081
name: http
envFrom:
- configMapRef:
name: cm-common
name: phonebill-common-config
- configMapRef:
name: cm-user-service
name: user-service-config
- secretRef:
name: secret-common
name: phonebill-common-secret
- secretRef:
name: secret-user-service
name: user-service-db-secret
resources:
requests:
cpu: 256m
memory: 256Mi
cpu: "256m"
memory: "256Mi"
limits:
cpu: 1024m
memory: 1024Mi
startupProbe:
httpGet:
path: /actuator/health
port: 8081
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 6
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8081
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
cpu: "1024m"
memory: "1024Mi"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8081
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8081
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 5
failureThreshold: 3
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: phonebill-ingress
namespace: phonebill
labels:
app.kubernetes.io/part-of: phonebill
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
spec:
ingressClassName: nginx
rules:
- host: phonebill-api.72.155.72.236.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-gateway
port:
number: 8080
-6
View File
@@ -1,6 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-kos-mock
data:
SERVER_PORT: "8084"
-11
View File
@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: kos-mock
spec:
selector:
app: kos-mock
ports:
- port: 80
targetPort: 8084
type: ClusterIP
@@ -1,10 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-product-service
data:
SERVER_PORT: "8083"
DB_KIND: "postgresql"
DB_PORT: "5432"
KOS_BASE_URL: "http://kos-mock"
REDIS_DATABASE: "2"
@@ -1,10 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-product-service
type: Opaque
stringData:
DB_HOST: "product-change-postgres-dev-postgresql"
DB_NAME: "product_change_db"
DB_USERNAME: "product_change_user"
DB_PASSWORD: "ProductUser2025@"
@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: product-service
spec:
selector:
app: product-service
ports:
- port: 80
targetPort: 8083
type: ClusterIP
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: bill-service-db-secret
namespace: phonebill
labels:
app: bill-service
app.kubernetes.io/part-of: phonebill
type: Opaque
stringData:
DB_USERNAME: "unicorn"
DB_PASSWORD: "P@ssw0rd$"
+13
View File
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: phonebill-common-secret
namespace: phonebill
labels:
app.kubernetes.io/part-of: phonebill
type: Opaque
stringData:
# JWT Secret (최소 256비트 이상, HS256 알고리즘용)
JWT_SECRET: "EK1ZV7vROOXREXbYe/BCISdQq0Yklk9JtoA2v88ux1DBDc0bDGiRRxHeDSb7GHkDP9IUYHMVsBi4/1rS4OhfRg=="
# Redis 비밀번호 (비밀번호 없는 경우 빈 값)
REDIS_PASSWORD: "P@ssw0rd$"
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: product-service-db-secret
namespace: phonebill
labels:
app: product-service
app.kubernetes.io/part-of: phonebill
type: Opaque
stringData:
DB_USERNAME: "unicorn"
DB_PASSWORD: "P@ssw0rd$"
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: user-service-db-secret
namespace: phonebill
labels:
app: user-service
app.kubernetes.io/part-of: phonebill
type: Opaque
stringData:
DB_USERNAME: "unicorn"
DB_PASSWORD: "P@ssw0rd$"
@@ -2,10 +2,16 @@ apiVersion: v1
kind: Service
metadata:
name: api-gateway
namespace: phonebill
labels:
app: api-gateway
app.kubernetes.io/part-of: phonebill
spec:
type: ClusterIP
selector:
app: api-gateway
ports:
- port: 80
- name: http
port: 8080
targetPort: 8080
type: ClusterIP
protocol: TCP
+17
View File
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: bill-service
namespace: phonebill
labels:
app: bill-service
app.kubernetes.io/part-of: phonebill
spec:
type: ClusterIP
selector:
app: bill-service
ports:
- name: http
port: 8082
targetPort: 8082
protocol: TCP
+17
View File
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: kos-mock
namespace: phonebill
labels:
app: kos-mock
app.kubernetes.io/part-of: phonebill
spec:
type: ClusterIP
selector:
app: kos-mock
ports:
- name: http
port: 8084
targetPort: 8084
protocol: TCP
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: product-service
namespace: phonebill
labels:
app: product-service
app.kubernetes.io/part-of: phonebill
spec:
type: ClusterIP
selector:
app: product-service
ports:
- name: http
port: 8083
targetPort: 8083
protocol: TCP
+17
View File
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: user-service
namespace: phonebill
labels:
app: user-service
app.kubernetes.io/part-of: phonebill
spec:
type: ClusterIP
selector:
app: user-service
ports:
- name: http
port: 8081
targetPort: 8081
protocol: TCP
@@ -1,11 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-user-service
data:
SERVER_PORT: "8081"
DB_KIND: "postgresql"
DB_PORT: "5432"
DDL_AUTO: "update"
REDIS_DATABASE: "0"
SHOW_SQL: "true"
@@ -1,10 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-user-service
type: Opaque
stringData:
DB_HOST: "auth-postgres-dev-postgresql"
DB_NAME: "phonebill_auth"
DB_USERNAME: "auth_user"
DB_PASSWORD: "AuthUser2025@"
-11
View File
@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: user-service
spec:
selector:
app: user-service
ports:
- port: 80
targetPort: 8081
type: ClusterIP