diff --git a/smarketing-java/deployment/Jenkinsfile b/smarketing-java/deployment/Jenkinsfile index 685d9b3..b2934e3 100644 --- a/smarketing-java/deployment/Jenkinsfile +++ b/smarketing-java/deployment/Jenkinsfile @@ -176,37 +176,43 @@ podTemplate( sh """ echo "=== 환경변수 설정 ===" export namespace=${namespace} - export allowed_origins=${props.allowed_origins} - export jwt_secret_key=${props.jwt_secret_key} - export postgres_user=${props.postgres_user} - export postgres_password=${props.postgres_password} + export allowed_origins='${props.allowed_origins}' + export jwt_secret_key='${props.jwt_secret_key}' + export postgres_user='${props.POSTGRES_USER}' + export postgres_password='${props.POSTGRES_PASSWORD}' export replicas=${props.replicas} - - # PostgreSQL 환경변수 추가 - export postgres_host=${props.POSTGRES_HOST} - export postgres_port=${props.POSTGRES_PORT:-5432} - export postgres_db_member=member - export postgres_db_store=store - export postgres_db_marketing_content=marketing_content - export postgres_db_ai_recommend=AiRecommendationDB - - # Redis 환경변수 추가 - export redis_host=${props.REDIS_HOST} - export redis_port=${props.REDIS_PORT} - export redis_password=${props.REDIS_PASSWORD} - - # 리소스 요구사항 조정 (작게) - export resources_requests_cpu=100m - export resources_requests_memory=128Mi - export resources_limits_cpu=500m - export resources_limits_memory=512Mi + # PostgreSQL 환경변수 추가 (문자열로) + export postgres_host='${props.POSTGRES_HOST}' + export postgres_port='5432' + export postgres_db_member='member' + export postgres_db_store='store' + export postgres_db_marketing_content='marketing_content' + export postgres_db_ai_recommend='AiRecommendationDB' + + # Redis 환경변수 추가 (문자열로) + export redis_host='${props.REDIS_HOST}' + export redis_port='6380' + export redis_password='${props.REDIS_PASSWORD}' + + # 리소스 요구사항 + export resources_requests_cpu='${props.resources_requests_cpu}' + export resources_requests_memory='${props.resources_requests_memory}' + export resources_limits_cpu='${props.resources_limits_cpu}' + export resources_limits_memory='${props.resources_limits_memory}' # 이미지 경로 환경변수 설정 - export member_image_path=${props.registry}/${props.image_org}/member:${imageTag} - export store_image_path=${props.registry}/${props.image_org}/store:${imageTag} - export marketing_content_image_path=${props.registry}/${props.image_org}/marketing-content:${imageTag} - export ai_recommend_image_path=${props.registry}/${props.image_org}/ai-recommend:${imageTag} + export member_image_path='${props.registry}/${props.image_org}/member:${imageTag}' + export store_image_path='${props.registry}/${props.image_org}/store:${imageTag}' + export marketing_content_image_path='${props.registry}/${props.image_org}/marketing-content:${imageTag}' + export ai_recommend_image_path='${props.registry}/${props.image_org}/ai-recommend:${imageTag}' + + echo "=== 환경변수 확인 ===" + echo "postgres_host: \$postgres_host" + echo "postgres_port: \$postgres_port" + echo "redis_host: \$redis_host" + echo "redis_port: \$redis_port" + echo "postgres_user: \$postgres_user" echo "=== Manifest 생성 ===" envsubst < smarketing-java/deployment/${manifest}.template > smarketing-java/deployment/${manifest} @@ -223,30 +229,42 @@ podTemplate( kubectl config current-context kubectl cluster-info | head -3 + echo "=== 기존 ConfigMap 삭제 (타입 충돌 해결) ===" + kubectl delete configmap member-config store-config marketing-content-config ai-recommend-config -n ${namespace} --ignore-not-found=true + echo "=== PostgreSQL 서비스 확인 ===" - kubectl get svc -n ${namespace} | grep postgresql || echo "PostgreSQL 서비스가 없습니다. 먼저 설치해주세요." + kubectl get svc -n ${namespace} | grep postgresql || echo "PostgreSQL 서비스가 없습니다." echo "=== Manifest 적용 ===" kubectl apply -f smarketing-java/deployment/${manifest} - echo "=== 배포 상태 확인 (60초 대기) ===" + echo "=== 배포 상태 확인 (30초 대기) ===" + sleep 30 kubectl -n ${namespace} get deployments kubectl -n ${namespace} get pods - echo "=== 각 서비스 배포 대기 (60초 timeout) ===" - timeout 60 kubectl -n ${namespace} wait --for=condition=available deployment/member --timeout=60s || echo "member deployment 대기 타임아웃" - timeout 60 kubectl -n ${namespace} wait --for=condition=available deployment/store --timeout=60s || echo "store deployment 대기 타임아웃" - timeout 60 kubectl -n ${namespace} wait --for=condition=available deployment/marketing-content --timeout=60s || echo "marketing-content deployment 대기 타임아웃" - timeout 60 kubectl -n ${namespace} wait --for=condition=available deployment/ai-recommend --timeout=60s || echo "ai-recommend deployment 대기 타임아웃" + echo "=== ConfigMap 확인 ===" + kubectl -n ${namespace} get configmap ai-recommend-config -o yaml + + echo "=== 각 서비스 배포 대기 (90초 timeout) ===" + timeout 90 kubectl -n ${namespace} wait --for=condition=available deployment/member --timeout=90s || echo "member deployment 대기 타임아웃" + timeout 90 kubectl -n ${namespace} wait --for=condition=available deployment/store --timeout=90s || echo "store deployment 대기 타임아웃" + timeout 90 kubectl -n ${namespace} wait --for=condition=available deployment/marketing-content --timeout=90s || echo "marketing-content deployment 대기 타임아웃" + timeout 90 kubectl -n ${namespace} wait --for=condition=available deployment/ai-recommend --timeout=90s || echo "ai-recommend deployment 대기 타임아웃" echo "=== 최종 상태 ===" kubectl -n ${namespace} get all + echo "=== Pod 로그 확인 (ai-recommend) ===" + kubectl -n ${namespace} logs deployment/ai-recommend --tail=50 || echo "ai-recommend 로그를 가져올 수 없습니다" + echo "=== 실패한 Pod 상세 정보 ===" for pod in \$(kubectl -n ${namespace} get pods --field-selector=status.phase!=Running -o name 2>/dev/null || true); do if [ ! -z "\$pod" ]; then echo "=== 실패한 Pod: \$pod ===" - kubectl -n ${namespace} describe \$pod | tail -20 + kubectl -n ${namespace} describe \$pod | tail -30 + echo "=== Pod 로그: \$pod ===" + kubectl -n ${namespace} logs \$pod --tail=20 || echo "로그를 가져올 수 없습니다" fi done """ diff --git a/smarketing-java/deployment/deploy.yaml.template b/smarketing-java/deployment/deploy.yaml.template index 0a45408..0416d61 100644 --- a/smarketing-java/deployment/deploy.yaml.template +++ b/smarketing-java/deployment/deploy.yaml.template @@ -8,16 +8,11 @@ data: ALLOWED_ORIGINS: ${allowed_origins} JPA_DDL_AUTO: update JPA_SHOW_SQL: 'true' - # 🔧 강화된 Actuator 설정 + # Actuator 설정 MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: '*' MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS: always MANAGEMENT_ENDPOINT_HEALTH_ENABLED: 'true' MANAGEMENT_ENDPOINTS_WEB_BASE_PATH: /actuator - MANAGEMENT_SERVER_PORT: '8080' - # Spring Security 비활성화 (Actuator용) - SPRING_AUTOCONFIGURE_EXCLUDE: org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration - # 또는 Management port를 main port와 동일하게 - MANAGEMENT_SERVER_PORT: '' --- apiVersion: v1 @@ -28,10 +23,10 @@ metadata: data: SERVER_PORT: '8081' POSTGRES_HOST: ${postgres_host} - POSTGRES_PORT: ${postgres_port} - POSTGRES_DB: ${postgres_db_ai_recommend} + POSTGRES_PORT: '5432' + POSTGRES_DB: ${postgres_db_member} REDIS_HOST: ${redis_host} - REDIS_PORT: ${redis_port} + REDIS_PORT: '6380' JPA_DDL_AUTO: 'create-drop' JPA_SHOW_SQL: 'true' @@ -44,10 +39,10 @@ metadata: data: SERVER_PORT: '8082' POSTGRES_HOST: ${postgres_host} - POSTGRES_PORT: ${postgres_port} - POSTGRES_DB: ${postgres_db_ai_recommend} + POSTGRES_PORT: '5432' + POSTGRES_DB: ${postgres_db_store} REDIS_HOST: ${redis_host} - REDIS_PORT: ${redis_port} + REDIS_PORT: '6380' JPA_DDL_AUTO: 'create-drop' JPA_SHOW_SQL: 'true' @@ -60,14 +55,13 @@ metadata: data: SERVER_PORT: '8083' POSTGRES_HOST: ${postgres_host} - POSTGRES_PORT: ${postgres_port} - POSTGRES_DB: ${postgres_db_ai_recommend} + POSTGRES_PORT: '5432' + POSTGRES_DB: ${postgres_db_marketing_content} REDIS_HOST: ${redis_host} - REDIS_PORT: ${redis_port} + REDIS_PORT: '6380' JPA_DDL_AUTO: 'create-drop' JPA_SHOW_SQL: 'true' - --- apiVersion: v1 kind: ConfigMap @@ -77,10 +71,10 @@ metadata: data: SERVER_PORT: '8084' POSTGRES_HOST: ${postgres_host} - POSTGRES_PORT: ${postgres_port} + POSTGRES_PORT: '5432' POSTGRES_DB: ${postgres_db_ai_recommend} REDIS_HOST: ${redis_host} - REDIS_PORT: ${redis_port} + REDIS_PORT: '6380' JPA_DDL_AUTO: 'create-drop' JPA_SHOW_SQL: 'true' @@ -189,35 +183,25 @@ spec: - secretRef: name: member-secret startupProbe: - exec: - command: - - /bin/sh - - -c - - "nc -z member-postgresql 5432" + tcpSocket: + port: 8081 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 10 - # 🔧 개선된 Health Check 설정 livenessProbe: httpGet: path: /actuator/health port: 8081 - httpHeaders: - - name: Accept - value: application/json - initialDelaySeconds: 120 # 2분으로 증가 + initialDelaySeconds: 120 periodSeconds: 30 timeoutSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: - path: /actuator/health/readiness + path: /actuator/health port: 8081 - httpHeaders: - - name: Accept - value: application/json - initialDelaySeconds: 60 # 1분으로 증가 + initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 3 @@ -265,11 +249,8 @@ spec: - secretRef: name: store-secret startupProbe: - exec: - command: - - /bin/sh - - -c - - "nc -z store-postgresql 5432" + tcpSocket: + port: 8082 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 @@ -278,20 +259,14 @@ spec: httpGet: path: /actuator/health port: 8082 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 120 periodSeconds: 30 timeoutSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: - path: /actuator/health/readiness + path: /actuator/health port: 8082 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 5 @@ -340,11 +315,8 @@ spec: - secretRef: name: marketing-content-secret startupProbe: - exec: - command: - - /bin/sh - - -c - - "nc -z marketing-content-postgresql 5432" + tcpSocket: + port: 8083 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 @@ -353,20 +325,14 @@ spec: httpGet: path: /actuator/health port: 8083 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 120 periodSeconds: 30 timeoutSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: - path: /actuator/health/readiness + path: /actuator/health port: 8083 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 5 @@ -415,11 +381,8 @@ spec: - secretRef: name: ai-recommend-secret startupProbe: - exec: - command: - - /bin/sh - - -c - - "nc -z ai-recommend-postgresql 5432" + tcpSocket: + port: 8084 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 @@ -428,20 +391,14 @@ spec: httpGet: path: /actuator/health port: 8084 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 120 periodSeconds: 30 timeoutSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: - path: /actuator/health/readiness + path: /actuator/health port: 8084 - httpHeaders: - - name: Accept - value: application/json initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 5