mirror of
https://github.com/won-ktds/smarketing-backend.git
synced 2025-12-06 07:06:24 +00:00
Merge branch 'main' of https://github.com/won-ktds/smarketing-backend into poster-content
This commit is contained in:
commit
4bb7882dd3
1
smarketing-ai/GITOPS_TEST.md
Normal file
1
smarketing-ai/GITOPS_TEST.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# GitOps Test Thu Jun 19 07:13:03 UTC 2025
|
||||||
308
smarketing-ai/deployment/Jenkinsfile
vendored
308
smarketing-ai/deployment/Jenkinsfile
vendored
@ -1,3 +1,5 @@
|
|||||||
|
// smarketing-backend/smarketing-ai/deployment/Jenkinsfile
|
||||||
|
|
||||||
def PIPELINE_ID = "${env.BUILD_NUMBER}"
|
def PIPELINE_ID = "${env.BUILD_NUMBER}"
|
||||||
|
|
||||||
def getImageTag() {
|
def getImageTag() {
|
||||||
@ -11,166 +13,184 @@ podTemplate(
|
|||||||
serviceAccount: 'jenkins',
|
serviceAccount: 'jenkins',
|
||||||
containers: [
|
containers: [
|
||||||
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
|
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
|
||||||
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true),
|
containerTemplate(name: 'git', image: 'alpine/git:latest', command: 'cat', ttyEnabled: true)
|
||||||
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h')
|
|
||||||
],
|
],
|
||||||
volumes: [
|
volumes: [
|
||||||
emptyDirVolume(mountPath: '/run/podman', memory: false),
|
emptyDirVolume(mountPath: '/run/podman', memory: false)
|
||||||
emptyDirVolume(mountPath: '/root/.azure', memory: false)
|
|
||||||
]
|
]
|
||||||
) {
|
) {
|
||||||
node(PIPELINE_ID) {
|
node(PIPELINE_ID) {
|
||||||
def props
|
def props
|
||||||
def imageTag = getImageTag()
|
def imageTag = getImageTag()
|
||||||
def manifest = "deploy.yaml"
|
|
||||||
def namespace
|
// Manifest Repository 설정
|
||||||
|
def MANIFEST_REPO = 'https://github.com/won-ktds/smarketing-manifest.git'
|
||||||
|
def MANIFEST_CREDENTIAL_ID = 'github-credentials-smarketing'
|
||||||
|
|
||||||
stage("Get Source") {
|
try {
|
||||||
checkout scm
|
stage("Get Source") {
|
||||||
props = readProperties file: "smarketing-ai/deployment/deploy_env_vars"
|
checkout scm
|
||||||
namespace = "${props.namespace}"
|
|
||||||
|
// smarketing-ai 하위에 있는 설정 파일 읽기
|
||||||
|
props = readProperties file: "smarketing-ai/deployment/deploy_env_vars"
|
||||||
|
|
||||||
echo "Registry: ${props.registry}"
|
echo "=== Build Information ==="
|
||||||
echo "Image Org: ${props.image_org}"
|
echo "Service: smarketing-ai"
|
||||||
echo "Team ID: ${props.teamid}"
|
echo "Image Tag: ${imageTag}"
|
||||||
}
|
echo "Registry: ${props.registry}"
|
||||||
|
echo "Image Org: ${props.image_org}"
|
||||||
stage("Check Changes") {
|
echo "Team ID: ${props.teamid}"
|
||||||
script {
|
|
||||||
def changes = sh(
|
|
||||||
script: "git diff --name-only HEAD~1 HEAD",
|
|
||||||
returnStdout: true
|
|
||||||
).trim()
|
|
||||||
|
|
||||||
echo "Changed files: ${changes}"
|
|
||||||
|
|
||||||
if (!changes.contains("smarketing-ai/")) {
|
|
||||||
echo "No changes in smarketing-ai, skipping build"
|
|
||||||
currentBuild.result = 'SUCCESS'
|
|
||||||
error("Stopping pipeline - no changes detected")
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Changes detected in smarketing-ai, proceeding with build"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage("Setup AKS") {
|
stage("Check Changes") {
|
||||||
container('azure-cli') {
|
script {
|
||||||
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
def changes = sh(
|
||||||
sh """
|
script: "git diff --name-only HEAD~1 HEAD",
|
||||||
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
returnStdout: true
|
||||||
az aks get-credentials --resource-group rg-digitalgarage-02 --name aks-digitalgarage-02 --overwrite-existing
|
).trim()
|
||||||
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
|
||||||
|
echo "Changed files: ${changes}"
|
||||||
|
|
||||||
|
if (!changes.contains("smarketing-ai/")) {
|
||||||
|
echo "No changes in smarketing-ai, skipping build"
|
||||||
|
currentBuild.result = 'SUCCESS'
|
||||||
|
error("Stopping pipeline - no changes detected")
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Changes detected in smarketing-ai, proceeding with build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build & Push Docker Image') {
|
||||||
|
container('podman') {
|
||||||
|
sh 'podman system service -t 0 unix:///run/podman/podman.sock & sleep 2'
|
||||||
|
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: 'acr-credentials',
|
||||||
|
usernameVariable: 'ACR_USERNAME',
|
||||||
|
passwordVariable: 'ACR_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Building smarketing-ai Python Flask application"
|
||||||
|
echo "Image Tag: ${imageTag}"
|
||||||
|
echo "=========================================="
|
||||||
|
|
||||||
|
# ACR 로그인
|
||||||
|
echo \$ACR_PASSWORD | podman login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
||||||
|
|
||||||
|
# Docker 이미지 빌드
|
||||||
|
podman build \\
|
||||||
|
-f smarketing-ai/deployment/Dockerfile \\
|
||||||
|
-t ${props.registry}/${props.image_org}/smarketing-ai:${imageTag} .
|
||||||
|
|
||||||
|
# 이미지 푸시
|
||||||
|
podman push ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
||||||
|
|
||||||
|
echo "Successfully built and pushed: ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Update Manifest Repository') {
|
||||||
|
container('git') {
|
||||||
|
script {
|
||||||
|
// Manifest Repository Clone
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: MANIFEST_CREDENTIAL_ID,
|
||||||
|
usernameVariable: 'GIT_USERNAME',
|
||||||
|
passwordVariable: 'GIT_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=== Git 설정 ==="
|
||||||
|
git config --global user.name "Jenkins CI"
|
||||||
|
git config --global user.email "jenkins@company.com"
|
||||||
|
|
||||||
|
echo "=== Manifest Repository Clone ==="
|
||||||
|
rm -rf manifest-repo
|
||||||
|
git clone https://\$GIT_USERNAME:\$GIT_PASSWORD@github.com/won-ktds/smarketing-manifest.git manifest-repo
|
||||||
|
cd manifest-repo
|
||||||
|
"""
|
||||||
|
|
||||||
|
def fullImageName = "${props.registry}/${props.image_org}/smarketing-ai:${imageTag}"
|
||||||
|
def deploymentFile = "smarketing-ai/deployments/smarketing-ai/smarketing-ai-deployment.yaml"
|
||||||
|
|
||||||
|
sh """
|
||||||
|
cd manifest-repo
|
||||||
|
|
||||||
|
echo "=== smarketing-ai 이미지 태그 업데이트 ==="
|
||||||
|
if [ -f "${deploymentFile}" ]; then
|
||||||
|
# 이미지 태그 업데이트 (sed 사용)
|
||||||
|
sed -i 's|image: ${props.registry}/${props.image_org}/smarketing-ai:.*|image: ${fullImageName}|g' "${deploymentFile}"
|
||||||
|
echo "Updated ${deploymentFile} with new image: ${fullImageName}"
|
||||||
|
|
||||||
|
# 변경사항 확인
|
||||||
|
echo "=== 변경된 내용 확인 ==="
|
||||||
|
grep "image: ${props.registry}/${props.image_org}/smarketing-ai" "${deploymentFile}" || echo "이미지 태그 업데이트 확인 실패"
|
||||||
|
else
|
||||||
|
echo "Warning: ${deploymentFile} not found"
|
||||||
|
fi
|
||||||
|
"""
|
||||||
|
|
||||||
|
sh """
|
||||||
|
cd manifest-repo
|
||||||
|
|
||||||
|
echo "=== Git 변경사항 확인 ==="
|
||||||
|
git status
|
||||||
|
git diff
|
||||||
|
|
||||||
|
# 변경사항이 있으면 커밋 및 푸시
|
||||||
|
if [ -n "\$(git status --porcelain)" ]; then
|
||||||
|
git add .
|
||||||
|
git commit -m "Update smarketing-ai to ${imageTag} - Build ${env.BUILD_NUMBER}"
|
||||||
|
git push origin main
|
||||||
|
echo "✅ Successfully updated manifest repository"
|
||||||
|
else
|
||||||
|
echo "ℹ️ No changes to commit"
|
||||||
|
fi
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Trigger ArgoCD Sync') {
|
||||||
|
script {
|
||||||
|
echo """
|
||||||
|
🎯 smarketing-ai CI Pipeline 완료!
|
||||||
|
|
||||||
|
📦 빌드된 이미지:
|
||||||
|
- ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
||||||
|
|
||||||
|
🔄 ArgoCD 동작:
|
||||||
|
- ArgoCD가 manifest repository 변경사항을 자동으로 감지합니다
|
||||||
|
- smarketing-ai Application이 새로운 이미지로 동기화됩니다
|
||||||
|
- ArgoCD UI에서 배포 상태를 모니터링하세요
|
||||||
|
|
||||||
|
🌐 ArgoCD UI: [ArgoCD 접속 URL]
|
||||||
|
📁 Manifest Repo: ${MANIFEST_REPO}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build & Push Docker Image') {
|
// 성공 시 처리
|
||||||
|
echo """
|
||||||
|
✅ smarketing-ai CI Pipeline 성공!
|
||||||
|
🏷️ 새로운 이미지 태그: ${imageTag}
|
||||||
|
🔄 ArgoCD가 자동으로 배포를 시작합니다
|
||||||
|
"""
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 실패 시 처리
|
||||||
|
echo "❌ smarketing-ai CI Pipeline 실패: ${e.getMessage()}"
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
// 정리 작업 (항상 실행)
|
||||||
container('podman') {
|
container('podman') {
|
||||||
sh 'podman system service -t 0 unix:///run/podman/podman.sock & sleep 2'
|
sh 'podman system prune -f || true'
|
||||||
|
|
||||||
withCredentials([usernamePassword(
|
|
||||||
credentialsId: 'acr-credentials',
|
|
||||||
usernameVariable: 'ACR_USERNAME',
|
|
||||||
passwordVariable: 'ACR_PASSWORD'
|
|
||||||
)]) {
|
|
||||||
sh """
|
|
||||||
echo "=========================================="
|
|
||||||
echo "Building smarketing-ai Python Flask application"
|
|
||||||
echo "Image Tag: ${imageTag}"
|
|
||||||
echo "=========================================="
|
|
||||||
|
|
||||||
# ACR 로그인
|
|
||||||
echo \$ACR_PASSWORD | podman login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
|
||||||
|
|
||||||
# Docker 이미지 빌드
|
|
||||||
podman build \
|
|
||||||
-f smarketing-ai/deployment/Dockerfile \
|
|
||||||
-t ${props.registry}/${props.image_org}/smarketing-ai:${imageTag} .
|
|
||||||
|
|
||||||
# 이미지 푸시
|
|
||||||
podman push ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
|
||||||
|
|
||||||
echo "Successfully built and pushed: ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}"
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Generate & Apply Manifest') {
|
|
||||||
container('envsubst') {
|
|
||||||
withCredentials([
|
|
||||||
string(credentialsId: 'SECRET_KEY', variable: 'SECRET_KEY'),
|
|
||||||
string(credentialsId: 'CLAUDE_API_KEY', variable: 'CLAUDE_API_KEY'),
|
|
||||||
string(credentialsId: 'OPENAI_API_KEY', variable: 'OPENAI_API_KEY'),
|
|
||||||
string(credentialsId: 'AZURE_STORAGE_ACCOUNT_NAME', variable: 'AZURE_STORAGE_ACCOUNT_NAME'),
|
|
||||||
string(credentialsId: 'AZURE_STORAGE_ACCOUNT_KEY', variable: 'AZURE_STORAGE_ACCOUNT_KEY')
|
|
||||||
]) {
|
|
||||||
sh """
|
|
||||||
export namespace=${namespace}
|
|
||||||
export replicas=${props.replicas}
|
|
||||||
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 upload_folder=${props.upload_folder}
|
|
||||||
export max_content_length=${props.max_content_length}
|
|
||||||
export allowed_extensions=${props.allowed_extensions}
|
|
||||||
export server_host=${props.server_host}
|
|
||||||
export server_port=${props.server_port}
|
|
||||||
export azure_storage_container_name=${props.azure_storage_container_name}
|
|
||||||
|
|
||||||
# 이미지 경로 환경변수 설정
|
|
||||||
export smarketing_image_path=${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
|
||||||
|
|
||||||
# Sensitive 환경변수 설정 (Jenkins Credentials에서)
|
|
||||||
export secret_key=\$SECRET_KEY
|
|
||||||
export claude_api_key=\$CLAUDE_API_KEY
|
|
||||||
export openai_api_key=\$OPENAI_API_KEY
|
|
||||||
export azure_storage_account_name=\$AZURE_STORAGE_ACCOUNT_NAME
|
|
||||||
export azure_storage_account_key=\$AZURE_STORAGE_ACCOUNT_KEY
|
|
||||||
|
|
||||||
# manifest 생성
|
|
||||||
envsubst < smarketing-ai/deployment/${manifest}.template > smarketing-ai/deployment/${manifest}
|
|
||||||
echo "Generated manifest file:"
|
|
||||||
cat smarketing-ai/deployment/${manifest}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
container('azure-cli') {
|
|
||||||
sh """
|
|
||||||
kubectl apply -f smarketing-ai/deployment/${manifest}
|
|
||||||
|
|
||||||
echo "Waiting for smarketing deployment to be ready..."
|
|
||||||
kubectl -n ${namespace} wait --for=condition=available deployment/smarketing --timeout=300s
|
|
||||||
|
|
||||||
echo "=========================================="
|
|
||||||
echo "Getting LoadBalancer External IP..."
|
|
||||||
|
|
||||||
# External IP 확인 (최대 5분 대기)
|
|
||||||
for i in {1..30}; do
|
|
||||||
EXTERNAL_IP=\$(kubectl -n ${namespace} get service smarketing-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
|
||||||
if [ "\$EXTERNAL_IP" != "" ] && [ "\$EXTERNAL_IP" != "null" ]; then
|
|
||||||
echo "External IP assigned: \$EXTERNAL_IP"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "Waiting for External IP... (attempt \$i/30)"
|
|
||||||
sleep 10
|
|
||||||
done
|
|
||||||
|
|
||||||
# 서비스 상태 확인
|
|
||||||
kubectl -n ${namespace} get pods -l app=smarketing
|
|
||||||
kubectl -n ${namespace} get service smarketing-service
|
|
||||||
|
|
||||||
echo "=========================================="
|
|
||||||
echo "Deployment Complete!"
|
|
||||||
echo "Service URL: http://\$EXTERNAL_IP:${props.server_port}"
|
|
||||||
echo "Health Check: http://\$EXTERNAL_IP:${props.server_port}/health"
|
|
||||||
echo "=========================================="
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
|
sh 'rm -rf manifest-repo || true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
176
smarketing-ai/deployment/Jenkinsfile_backup
Normal file
176
smarketing-ai/deployment/Jenkinsfile_backup
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
def PIPELINE_ID = "${env.BUILD_NUMBER}"
|
||||||
|
|
||||||
|
def getImageTag() {
|
||||||
|
def dateFormat = new java.text.SimpleDateFormat('yyyyMMddHHmmss')
|
||||||
|
def currentDate = new Date()
|
||||||
|
return dateFormat.format(currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
podTemplate(
|
||||||
|
label: "${PIPELINE_ID}",
|
||||||
|
serviceAccount: 'jenkins',
|
||||||
|
containers: [
|
||||||
|
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
|
||||||
|
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true),
|
||||||
|
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h')
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
emptyDirVolume(mountPath: '/run/podman', memory: false),
|
||||||
|
emptyDirVolume(mountPath: '/root/.azure', memory: false)
|
||||||
|
]
|
||||||
|
) {
|
||||||
|
node(PIPELINE_ID) {
|
||||||
|
def props
|
||||||
|
def imageTag = getImageTag()
|
||||||
|
def manifest = "deploy.yaml"
|
||||||
|
def namespace
|
||||||
|
|
||||||
|
stage("Get Source") {
|
||||||
|
checkout scm
|
||||||
|
props = readProperties file: "smarketing-ai/deployment/deploy_env_vars"
|
||||||
|
namespace = "${props.namespace}"
|
||||||
|
|
||||||
|
echo "Registry: ${props.registry}"
|
||||||
|
echo "Image Org: ${props.image_org}"
|
||||||
|
echo "Team ID: ${props.teamid}"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Check Changes") {
|
||||||
|
script {
|
||||||
|
def changes = sh(
|
||||||
|
script: "git diff --name-only HEAD~1 HEAD",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
echo "Changed files: ${changes}"
|
||||||
|
|
||||||
|
if (!changes.contains("smarketing-ai/")) {
|
||||||
|
echo "No changes in smarketing-ai, skipping build"
|
||||||
|
currentBuild.result = 'SUCCESS'
|
||||||
|
error("Stopping pipeline - no changes detected")
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Changes detected in smarketing-ai, proceeding with build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Setup AKS") {
|
||||||
|
container('azure-cli') {
|
||||||
|
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
||||||
|
sh """
|
||||||
|
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
||||||
|
az aks get-credentials --resource-group rg-digitalgarage-02 --name aks-digitalgarage-02 --overwrite-existing
|
||||||
|
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build & Push Docker Image') {
|
||||||
|
container('podman') {
|
||||||
|
sh 'podman system service -t 0 unix:///run/podman/podman.sock & sleep 2'
|
||||||
|
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: 'acr-credentials',
|
||||||
|
usernameVariable: 'ACR_USERNAME',
|
||||||
|
passwordVariable: 'ACR_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Building smarketing-ai Python Flask application"
|
||||||
|
echo "Image Tag: ${imageTag}"
|
||||||
|
echo "=========================================="
|
||||||
|
|
||||||
|
# ACR 로그인
|
||||||
|
echo \$ACR_PASSWORD | podman login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
||||||
|
|
||||||
|
# Docker 이미지 빌드
|
||||||
|
podman build \
|
||||||
|
-f smarketing-ai/deployment/Dockerfile \
|
||||||
|
-t ${props.registry}/${props.image_org}/smarketing-ai:${imageTag} .
|
||||||
|
|
||||||
|
# 이미지 푸시
|
||||||
|
podman push ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
||||||
|
|
||||||
|
echo "Successfully built and pushed: ${props.registry}/${props.image_org}/smarketing-ai:${imageTag}"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Generate & Apply Manifest') {
|
||||||
|
container('envsubst') {
|
||||||
|
withCredentials([
|
||||||
|
string(credentialsId: 'SECRET_KEY', variable: 'SECRET_KEY'),
|
||||||
|
string(credentialsId: 'CLAUDE_API_KEY', variable: 'CLAUDE_API_KEY'),
|
||||||
|
string(credentialsId: 'OPENAI_API_KEY', variable: 'OPENAI_API_KEY'),
|
||||||
|
string(credentialsId: 'AZURE_STORAGE_ACCOUNT_NAME', variable: 'AZURE_STORAGE_ACCOUNT_NAME'),
|
||||||
|
string(credentialsId: 'AZURE_STORAGE_ACCOUNT_KEY', variable: 'AZURE_STORAGE_ACCOUNT_KEY')
|
||||||
|
]) {
|
||||||
|
sh """
|
||||||
|
export namespace=${namespace}
|
||||||
|
export replicas=${props.replicas}
|
||||||
|
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 upload_folder=${props.upload_folder}
|
||||||
|
export max_content_length=${props.max_content_length}
|
||||||
|
export allowed_extensions=${props.allowed_extensions}
|
||||||
|
export server_host=${props.server_host}
|
||||||
|
export server_port=${props.server_port}
|
||||||
|
export azure_storage_container_name=${props.azure_storage_container_name}
|
||||||
|
|
||||||
|
# 이미지 경로 환경변수 설정
|
||||||
|
export smarketing_image_path=${props.registry}/${props.image_org}/smarketing-ai:${imageTag}
|
||||||
|
|
||||||
|
# Sensitive 환경변수 설정 (Jenkins Credentials에서)
|
||||||
|
export secret_key=\$SECRET_KEY
|
||||||
|
export claude_api_key=\$CLAUDE_API_KEY
|
||||||
|
export openai_api_key=\$OPENAI_API_KEY
|
||||||
|
export azure_storage_account_name=\$AZURE_STORAGE_ACCOUNT_NAME
|
||||||
|
export azure_storage_account_key=\$AZURE_STORAGE_ACCOUNT_KEY
|
||||||
|
|
||||||
|
# manifest 생성
|
||||||
|
envsubst < smarketing-ai/deployment/${manifest}.template > smarketing-ai/deployment/${manifest}
|
||||||
|
echo "Generated manifest file:"
|
||||||
|
cat smarketing-ai/deployment/${manifest}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
container('azure-cli') {
|
||||||
|
sh """
|
||||||
|
kubectl apply -f smarketing-ai/deployment/${manifest}
|
||||||
|
|
||||||
|
echo "Waiting for smarketing deployment to be ready..."
|
||||||
|
kubectl -n ${namespace} wait --for=condition=available deployment/smarketing --timeout=300s
|
||||||
|
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Getting LoadBalancer External IP..."
|
||||||
|
|
||||||
|
# External IP 확인 (최대 5분 대기)
|
||||||
|
for i in {1..30}; do
|
||||||
|
EXTERNAL_IP=\$(kubectl -n ${namespace} get service smarketing-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
||||||
|
if [ "\$EXTERNAL_IP" != "" ] && [ "\$EXTERNAL_IP" != "null" ]; then
|
||||||
|
echo "External IP assigned: \$EXTERNAL_IP"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for External IP... (attempt \$i/30)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
# 서비스 상태 확인
|
||||||
|
kubectl -n ${namespace} get pods -l app=smarketing
|
||||||
|
kubectl -n ${namespace} get service smarketing-service
|
||||||
|
|
||||||
|
echo "=========================================="
|
||||||
|
echo "Deployment Complete!"
|
||||||
|
echo "Service URL: http://\$EXTERNAL_IP:${props.server_port}"
|
||||||
|
echo "Health Check: http://\$EXTERNAL_IP:${props.server_port}/health"
|
||||||
|
echo "=========================================="
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,4 +24,4 @@ server_host=0.0.0.0
|
|||||||
server_port=5001
|
server_port=5001
|
||||||
|
|
||||||
# Azure Storage Settings (non-sensitive)
|
# Azure Storage Settings (non-sensitive)
|
||||||
azure_storage_container_name=ai-content
|
azure_storage_container_name=ai-content
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class PosterService:
|
|||||||
if temp_path:
|
if temp_path:
|
||||||
temp_files.append(temp_path)
|
temp_files.append(temp_path)
|
||||||
|
|
||||||
# 이미지 분석
|
# 이미지 분석 시작
|
||||||
image_info = self.image_processor.get_image_info(temp_path)
|
image_info = self.image_processor.get_image_info(temp_path)
|
||||||
image_description = self.ai_client.analyze_image(temp_path)
|
image_description = self.ai_client.analyze_image(temp_path)
|
||||||
colors = self.image_processor.analyze_colors(temp_path, 5)
|
colors = self.image_processor.analyze_colors(temp_path, 5)
|
||||||
|
|||||||
1
smarketing-java/GITOPS_TEST.md
Normal file
1
smarketing-java/GITOPS_TEST.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# GitOps Test Thu Jun 19 05:36:03 UTC 2025
|
||||||
459
smarketing-java/deployment/Jenkinsfile
vendored
459
smarketing-java/deployment/Jenkinsfile
vendored
@ -12,290 +12,269 @@ podTemplate(
|
|||||||
containers: [
|
containers: [
|
||||||
containerTemplate(name: 'gradle', image: 'gradle:jdk17', ttyEnabled: true, command: 'cat'),
|
containerTemplate(name: 'gradle', image: 'gradle:jdk17', ttyEnabled: true, command: 'cat'),
|
||||||
containerTemplate(name: 'docker', image: 'docker:20.10.16-dind', ttyEnabled: true, privileged: true),
|
containerTemplate(name: 'docker', image: 'docker:20.10.16-dind', ttyEnabled: true, privileged: true),
|
||||||
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true),
|
containerTemplate(name: 'git', image: 'alpine/git:latest', command: 'cat', ttyEnabled: true)
|
||||||
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h')
|
|
||||||
],
|
],
|
||||||
volumes: [
|
volumes: [
|
||||||
emptyDirVolume(mountPath: '/home/gradle/.gradle', memory: false),
|
emptyDirVolume(mountPath: '/home/gradle/.gradle', memory: false),
|
||||||
emptyDirVolume(mountPath: '/root/.azure', memory: false),
|
|
||||||
emptyDirVolume(mountPath: '/var/run', memory: false)
|
emptyDirVolume(mountPath: '/var/run', memory: false)
|
||||||
]
|
]
|
||||||
) {
|
) {
|
||||||
node(PIPELINE_ID) {
|
node(PIPELINE_ID) {
|
||||||
def props
|
def props
|
||||||
def imageTag = getImageTag()
|
def imageTag = getImageTag()
|
||||||
def manifest = "deploy.yaml"
|
|
||||||
def namespace
|
|
||||||
def services = ['member', 'store', 'marketing-content', 'ai-recommend']
|
def services = ['member', 'store', 'marketing-content', 'ai-recommend']
|
||||||
|
|
||||||
|
// Manifest Repository 설정
|
||||||
|
def MANIFEST_REPO = 'https://github.com/won-ktds/smarketing-manifest.git'
|
||||||
|
def MANIFEST_CREDENTIAL_ID = 'github-credentials-smarketing'
|
||||||
|
|
||||||
stage("Get Source") {
|
try {
|
||||||
checkout scm
|
stage("Get Source") {
|
||||||
|
checkout scm
|
||||||
// smarketing-java 하위에 있는 설정 파일 읽기
|
|
||||||
props = readProperties file: "smarketing-java/deployment/deploy_env_vars"
|
// smarketing-java 하위에 있는 설정 파일 읽기
|
||||||
namespace = "${props.namespace}"
|
props = readProperties file: "smarketing-java/deployment/deploy_env_vars"
|
||||||
|
|
||||||
echo "=== Build Information ==="
|
echo "=== Build Information ==="
|
||||||
echo "Services: ${services}"
|
echo "Services: ${services}"
|
||||||
echo "Namespace: ${namespace}"
|
echo "Image Tag: ${imageTag}"
|
||||||
echo "Image Tag: ${imageTag}"
|
echo "Registry: ${props.registry}"
|
||||||
echo "Registry: ${props.registry}"
|
echo "Image Org: ${props.image_org}"
|
||||||
echo "Image Org: ${props.image_org}"
|
|
||||||
}
|
// Azure Blob Storage 환경변수 확인
|
||||||
|
echo "=== Azure Blob Storage Configuration ==="
|
||||||
stage("Check Changes") {
|
echo "Storage Account: ${props.AZURE_STORAGE_ACCOUNT_NAME}"
|
||||||
script {
|
echo "Storage Container: ${props.AZURE_STORAGE_CONTAINER_NAME}"
|
||||||
def changes = sh(
|
echo "Menu Container: ${props.AZURE_STORAGE_MENU_CONTAINER}"
|
||||||
script: "git diff --name-only HEAD~1 HEAD",
|
echo "Store Container: ${props.AZURE_STORAGE_STORE_CONTAINER}"
|
||||||
returnStdout: true
|
|
||||||
).trim()
|
|
||||||
|
|
||||||
if (!changes.contains("smarketing-java/")) {
|
|
||||||
echo "No changes in smarketing-java, skipping build"
|
|
||||||
currentBuild.result = 'SUCCESS'
|
|
||||||
error("Stopping pipeline - no changes detected")
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Changes detected in smarketing-java, proceeding with build"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage("Setup AKS") {
|
stage("Check Changes") {
|
||||||
container('azure-cli') {
|
script {
|
||||||
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
def changes = sh(
|
||||||
|
script: "git diff --name-only HEAD~1 HEAD",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!changes.contains("smarketing-java/")) {
|
||||||
|
echo "No changes in smarketing-java, skipping build"
|
||||||
|
currentBuild.result = 'SUCCESS'
|
||||||
|
error("Stopping pipeline - no changes detected")
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Changes detected in smarketing-java, proceeding with build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Applications') {
|
||||||
|
container('gradle') {
|
||||||
sh """
|
sh """
|
||||||
echo "=== Azure 로그인 ==="
|
echo "=== smarketing-java 디렉토리로 이동 ==="
|
||||||
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
cd smarketing-java
|
||||||
az account set --subscription 2513dd36-7978-48e3-9a7c-b221d4874f66
|
|
||||||
|
|
||||||
echo "=== AKS 인증정보 가져오기 (rg-digitalgarage-02) ==="
|
echo "=== gradlew 권한 설정 ==="
|
||||||
az aks get-credentials --resource-group rg-digitalgarage-02 --name aks-digitalgarage-02 --overwrite-existing
|
chmod +x gradlew
|
||||||
|
|
||||||
echo "=== 네임스페이스 생성 ==="
|
echo "=== 전체 서비스 빌드 ==="
|
||||||
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
./gradlew :member:clean :member:build -x test
|
||||||
|
./gradlew :store:clean :store:build -x test
|
||||||
|
./gradlew :marketing-content:clean :marketing-content:build -x test
|
||||||
|
./gradlew :ai-recommend:clean :ai-recommend:build -x test
|
||||||
|
|
||||||
echo "=== Image Pull Secret 생성 ==="
|
echo "=== 빌드 결과 확인 ==="
|
||||||
kubectl create secret docker-registry acr-secret \\
|
find . -name "*.jar" -path "*/build/libs/*" | grep -v 'plain.jar'
|
||||||
--docker-server=${props.registry} \\
|
|
||||||
--docker-username=acrdigitalgarage02 \\
|
|
||||||
--docker-password=\$(az acr credential show --name acrdigitalgarage02 --query passwords[0].value -o tsv) \\
|
|
||||||
--namespace=${namespace} \\
|
|
||||||
--dry-run=client -o yaml | kubectl apply -f -
|
|
||||||
|
|
||||||
echo "=== 클러스터 상태 확인 ==="
|
|
||||||
kubectl get nodes
|
|
||||||
kubectl get ns ${namespace}
|
|
||||||
|
|
||||||
echo "=== 현재 연결된 클러스터 확인 ==="
|
|
||||||
kubectl config current-context
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build Applications') {
|
stage('Build & Push Images') {
|
||||||
container('gradle') {
|
container('docker') {
|
||||||
sh """
|
|
||||||
echo "=== smarketing-java 디렉토리로 이동 ==="
|
|
||||||
cd smarketing-java
|
|
||||||
|
|
||||||
echo "=== gradlew 권한 설정 ==="
|
|
||||||
chmod +x gradlew
|
|
||||||
|
|
||||||
echo "=== 전체 서비스 빌드 ==="
|
|
||||||
./gradlew :member:clean :member:build -x test
|
|
||||||
./gradlew :store:clean :store:build -x test
|
|
||||||
./gradlew :marketing-content:clean :marketing-content:build -x test
|
|
||||||
./gradlew :ai-recommend:clean :ai-recommend:build -x test
|
|
||||||
|
|
||||||
echo "=== 빌드 결과 확인 ==="
|
|
||||||
find . -name "*.jar" -path "*/build/libs/*" | grep -v 'plain.jar'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build & Push Images') {
|
|
||||||
container('docker') {
|
|
||||||
sh """
|
|
||||||
echo "=== Docker 데몬 시작 대기 ==="
|
|
||||||
timeout 30 sh -c 'until docker info; do sleep 1; done'
|
|
||||||
"""
|
|
||||||
|
|
||||||
// ACR Credential을 Jenkins에서 직접 사용
|
|
||||||
withCredentials([usernamePassword(
|
|
||||||
credentialsId: 'acr-credentials',
|
|
||||||
usernameVariable: 'ACR_USERNAME',
|
|
||||||
passwordVariable: 'ACR_PASSWORD'
|
|
||||||
)]) {
|
|
||||||
sh """
|
sh """
|
||||||
echo "=== Docker로 ACR 로그인 ==="
|
echo "=== Docker 데몬 시작 대기 ==="
|
||||||
echo "\$ACR_PASSWORD" | docker login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
timeout 30 sh -c 'until docker info; do sleep 1; done'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
services.each { service ->
|
// ACR Credential을 Jenkins에서 직접 사용
|
||||||
script {
|
withCredentials([usernamePassword(
|
||||||
def buildDir = "smarketing-java/${service}"
|
credentialsId: 'acr-credentials',
|
||||||
def fullImageName = "${props.registry}/${props.image_org}/${service}:${imageTag}"
|
usernameVariable: 'ACR_USERNAME',
|
||||||
|
passwordVariable: 'ACR_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=== Docker로 ACR 로그인 ==="
|
||||||
|
echo "\$ACR_PASSWORD" | docker login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
||||||
|
"""
|
||||||
|
|
||||||
echo "Building image for ${service}: ${fullImageName}"
|
services.each { service ->
|
||||||
|
script {
|
||||||
|
def buildDir = "smarketing-java/${service}"
|
||||||
|
def fullImageName = "${props.registry}/${props.image_org}/${service}:${imageTag}"
|
||||||
|
|
||||||
|
echo "Building image for ${service}: ${fullImageName}"
|
||||||
|
|
||||||
|
// 실제 JAR 파일명 동적 탐지
|
||||||
|
def actualJarFile = sh(
|
||||||
|
script: """
|
||||||
|
cd ${buildDir}/build/libs
|
||||||
|
ls *.jar | grep -v 'plain.jar' | head -1
|
||||||
|
""",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!actualJarFile) {
|
||||||
|
error "${service} JAR 파일을 찾을 수 없습니다"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "발견된 JAR 파일: ${actualJarFile}"
|
||||||
|
|
||||||
|
sh """
|
||||||
|
echo "=== ${service} 이미지 빌드 ==="
|
||||||
|
docker build \\
|
||||||
|
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \\
|
||||||
|
--build-arg ARTIFACTORY_FILE="${actualJarFile}" \\
|
||||||
|
-f smarketing-java/deployment/container/Dockerfile \\
|
||||||
|
-t ${fullImageName} .
|
||||||
|
|
||||||
|
echo "=== ${service} 이미지 푸시 ==="
|
||||||
|
docker push ${fullImageName}
|
||||||
|
|
||||||
|
echo "Successfully built and pushed: ${fullImageName}"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Update Manifest Repository') {
|
||||||
|
container('git') {
|
||||||
|
script {
|
||||||
|
// Manifest Repository Clone
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: MANIFEST_CREDENTIAL_ID,
|
||||||
|
usernameVariable: 'GIT_USERNAME',
|
||||||
|
passwordVariable: 'GIT_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=== Git 설정 ==="
|
||||||
|
git config --global user.name "Jenkins CI"
|
||||||
|
git config --global user.email "jenkins@company.com"
|
||||||
|
|
||||||
|
echo "=== Manifest Repository Clone ==="
|
||||||
|
rm -rf manifest-repo
|
||||||
|
git clone https://\$GIT_USERNAME:\$GIT_PASSWORD@github.com/won-ktds/smarketing-manifest.git manifest-repo
|
||||||
|
cd manifest-repo
|
||||||
|
"""
|
||||||
|
|
||||||
// 실제 JAR 파일명 동적 탐지
|
services.each { service ->
|
||||||
def actualJarFile = sh(
|
def fullImageName = "${props.registry}/${props.image_org}/${service}:${imageTag}"
|
||||||
script: """
|
def deploymentFile = "smarketing/deployments/${service}/${service}-deployment.yaml"
|
||||||
cd ${buildDir}/build/libs
|
|
||||||
ls *.jar | grep -v 'plain.jar' | head -1
|
sh """
|
||||||
""",
|
cd manifest-repo
|
||||||
returnStdout: true
|
|
||||||
).trim()
|
echo "=== ${service} Deployment 파일 업데이트 ==="
|
||||||
|
if [ -f "${deploymentFile}" ]; then
|
||||||
if (!actualJarFile) {
|
# 이미지 태그 업데이트
|
||||||
error "${service} JAR 파일을 찾을 수 없습니다"
|
sed -i 's|image: ${props.registry}/${props.image_org}/${service}:.*|image: ${fullImageName}|g' "${deploymentFile}"
|
||||||
|
echo "Updated ${deploymentFile} with new image: ${fullImageName}"
|
||||||
|
|
||||||
|
# Azure Blob Storage 환경변수 업데이트 (ConfigMap/Secret에 있는 경우)
|
||||||
|
# ConfigMap 업데이트
|
||||||
|
if [ -f "smarketing/configmaps/${service}-configmap.yaml" ]; then
|
||||||
|
echo "=== ${service} ConfigMap 업데이트 ==="
|
||||||
|
# ConfigMap에서 Azure Storage 관련 설정 업데이트
|
||||||
|
sed -i 's|AZURE_STORAGE_ACCOUNT_NAME:.*|AZURE_STORAGE_ACCOUNT_NAME: "${props.AZURE_STORAGE_ACCOUNT_NAME}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
sed -i 's|AZURE_STORAGE_CONTAINER_NAME:.*|AZURE_STORAGE_CONTAINER_NAME: "${props.AZURE_STORAGE_CONTAINER_NAME}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
sed -i 's|AZURE_STORAGE_MENU_CONTAINER:.*|AZURE_STORAGE_MENU_CONTAINER: "${props.AZURE_STORAGE_MENU_CONTAINER}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
sed -i 's|AZURE_STORAGE_STORE_CONTAINER:.*|AZURE_STORAGE_STORE_CONTAINER: "${props.AZURE_STORAGE_STORE_CONTAINER}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
sed -i 's|AZURE_STORAGE_ENDPOINT:.*|AZURE_STORAGE_ENDPOINT: "${props.AZURE_STORAGE_ENDPOINT}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
sed -i 's|AZURE_STORAGE_MAX_FILE_SIZE:.*|AZURE_STORAGE_MAX_FILE_SIZE: "${props.AZURE_STORAGE_MAX_FILE_SIZE}"|g' "smarketing/configmaps/${service}-configmap.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Secret 업데이트
|
||||||
|
if [ -f "smarketing/secrets/${service}-secret.yaml" ]; then
|
||||||
|
echo "=== ${service} Secret 업데이트 ==="
|
||||||
|
# Base64 인코딩된 Azure Storage Account Key 업데이트
|
||||||
|
ENCODED_KEY=\$(echo -n "${props.AZURE_STORAGE_ACCOUNT_KEY}" | base64 -w 0)
|
||||||
|
sed -i "s|AZURE_STORAGE_ACCOUNT_KEY:.*|AZURE_STORAGE_ACCOUNT_KEY: \$ENCODED_KEY|g" "smarketing/secrets/${service}-secret.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 변경사항 확인
|
||||||
|
echo "=== 변경된 내용 확인 ==="
|
||||||
|
grep "image: ${props.registry}/${props.image_org}/${service}" "${deploymentFile}" || echo "이미지 태그 업데이트 확인 실패"
|
||||||
|
else
|
||||||
|
echo "Warning: ${deploymentFile} not found"
|
||||||
|
fi
|
||||||
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "발견된 JAR 파일: ${actualJarFile}"
|
|
||||||
|
|
||||||
sh """
|
sh """
|
||||||
echo "=== ${service} 이미지 빌드 ==="
|
cd manifest-repo
|
||||||
docker build \\
|
|
||||||
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \\
|
|
||||||
--build-arg ARTIFACTORY_FILE="${actualJarFile}" \\
|
|
||||||
-f smarketing-java/deployment/container/Dockerfile \\
|
|
||||||
-t ${fullImageName} .
|
|
||||||
|
|
||||||
echo "=== ${service} 이미지 푸시 ==="
|
|
||||||
docker push ${fullImageName}
|
|
||||||
|
|
||||||
echo "Successfully built and pushed: ${fullImageName}"
|
echo "=== Git 변경사항 확인 ==="
|
||||||
|
git status
|
||||||
|
git diff
|
||||||
|
|
||||||
|
# 변경사항이 있으면 커밋 및 푸시
|
||||||
|
if [ -n "\$(git status --porcelain)" ]; then
|
||||||
|
git add .
|
||||||
|
git commit -m "Update SMarketing services to ${imageTag} with Azure Storage config - Build ${env.BUILD_NUMBER}"
|
||||||
|
git push origin main
|
||||||
|
echo "✅ Successfully updated manifest repository with Azure Storage configuration"
|
||||||
|
else
|
||||||
|
echo "ℹ️ No changes to commit"
|
||||||
|
fi
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage('Generate & Apply Manifest') {
|
stage('Trigger ArgoCD Sync') {
|
||||||
container('envsubst') {
|
script {
|
||||||
sh """
|
echo """
|
||||||
echo "=== 환경변수 설정 ==="
|
🎯 CI Pipeline 완료!
|
||||||
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 replicas=${props.replicas}
|
|
||||||
|
|
||||||
# PostgreSQL 환경변수 추가 (올바른 DB명으로 수정)
|
|
||||||
export postgres_host='${props.POSTGRES_HOST}'
|
|
||||||
export postgres_port='5432'
|
|
||||||
export postgres_db_member='MemberDB'
|
|
||||||
export postgres_db_store='StoreDB'
|
|
||||||
export postgres_db_marketing_content='MarketingContentDB'
|
|
||||||
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}'
|
${services.collect { "- ${props.registry}/${props.image_org}/${it}:${imageTag}" }.join('\n')}
|
||||||
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 "=== 환경변수 확인 ==="
|
🔧 Azure Blob Storage 설정 업데이트:
|
||||||
echo "namespace: \$namespace"
|
- Storage Account: ${props.AZURE_STORAGE_ACCOUNT_NAME}
|
||||||
echo "postgres_host: \$postgres_host"
|
- Container: ${props.AZURE_STORAGE_CONTAINER_NAME}
|
||||||
echo "postgres_port: \$postgres_port"
|
- Menu Container: ${props.AZURE_STORAGE_MENU_CONTAINER}
|
||||||
echo "postgres_user: \$postgres_user"
|
- Store Container: ${props.AZURE_STORAGE_STORE_CONTAINER}
|
||||||
echo "postgres_db_member: \$postgres_db_member"
|
|
||||||
echo "postgres_db_store: \$postgres_db_store"
|
|
||||||
echo "postgres_db_marketing_content: \$postgres_db_marketing_content"
|
|
||||||
echo "postgres_db_ai_recommend: \$postgres_db_ai_recommend"
|
|
||||||
echo "redis_host: \$redis_host"
|
|
||||||
echo "redis_port: \$redis_port"
|
|
||||||
echo "replicas: \$replicas"
|
|
||||||
|
|
||||||
echo "=== Manifest 생성 ==="
|
🔄 ArgoCD 동작:
|
||||||
envsubst < smarketing-java/deployment/${manifest}.template > smarketing-java/deployment/${manifest}
|
- ArgoCD가 manifest repository 변경사항을 자동으로 감지합니다
|
||||||
|
- 각 서비스별 Application이 새로운 이미지로 동기화됩니다
|
||||||
echo "=== Generated Manifest File ==="
|
- Azure Blob Storage 환경변수가 ConfigMap/Secret에 반영됩니다
|
||||||
cat smarketing-java/deployment/${manifest}
|
- ArgoCD UI에서 배포 상태를 모니터링하세요
|
||||||
echo "==============================="
|
|
||||||
"""
|
🌐 ArgoCD UI: [ArgoCD 접속 URL]
|
||||||
|
📁 Manifest Repo: ${MANIFEST_REPO}
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
container('azure-cli') {
|
// 성공 시 처리
|
||||||
sh """
|
echo """
|
||||||
echo "=== 현재 연결된 클러스터 재확인 ==="
|
✅ CI Pipeline 성공!
|
||||||
kubectl config current-context
|
🏷️ 새로운 이미지 태그: ${imageTag}
|
||||||
kubectl cluster-info | head -3
|
🔧 Azure Blob Storage 설정 업데이트 완료
|
||||||
|
🔄 ArgoCD가 자동으로 배포를 시작합니다
|
||||||
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 서비스를 찾을 수 없습니다."
|
|
||||||
|
|
||||||
echo "=== Redis 서비스 확인 ==="
|
|
||||||
kubectl get svc -n ${namespace} | grep redis || echo "Redis 서비스를 찾을 수 없습니다."
|
|
||||||
|
|
||||||
echo "=== Manifest 적용 ==="
|
|
||||||
kubectl apply -f smarketing-java/deployment/${manifest}
|
|
||||||
|
|
||||||
echo "=== 배포 상태 확인 (30초 대기) ==="
|
} catch (Exception e) {
|
||||||
sleep 30
|
// 실패 시 처리
|
||||||
kubectl -n ${namespace} get deployments
|
echo "❌ CI Pipeline 실패: ${e.getMessage()}"
|
||||||
kubectl -n ${namespace} get pods
|
throw e
|
||||||
|
} finally {
|
||||||
echo "=== ConfigMap 확인 ==="
|
// 정리 작업 (항상 실행)
|
||||||
kubectl -n ${namespace} get configmap member-config -o yaml | grep -A 10 "data:"
|
container('docker') {
|
||||||
kubectl -n ${namespace} get configmap ai-recommend-config -o yaml | grep -A 10 "data:"
|
sh 'docker system prune -f || true'
|
||||||
|
|
||||||
echo "=== Secret 확인 ==="
|
|
||||||
kubectl -n ${namespace} get secret member-secret -o yaml | grep -A 5 "data:"
|
|
||||||
|
|
||||||
echo "=== 각 서비스 배포 대기 (120초 timeout) ==="
|
|
||||||
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/member --timeout=120s || echo "member deployment 대기 타임아웃"
|
|
||||||
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/store --timeout=120s || echo "store deployment 대기 타임아웃"
|
|
||||||
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/marketing-content --timeout=120s || echo "marketing-content deployment 대기 타임아웃"
|
|
||||||
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/ai-recommend --timeout=120s || echo "ai-recommend deployment 대기 타임아웃"
|
|
||||||
|
|
||||||
echo "=== 최종 배포 상태 ==="
|
|
||||||
kubectl -n ${namespace} get all
|
|
||||||
|
|
||||||
echo "=== 각 서비스 Pod 로그 확인 (최근 20라인) ==="
|
|
||||||
for service in member store marketing-content ai-recommend; do
|
|
||||||
echo "=== \$service 서비스 로그 ==="
|
|
||||||
kubectl -n ${namespace} logs deployment/\$service --tail=20 || echo "\$service 로그를 가져올 수 없습니다"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
|
|
||||||
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 -30
|
|
||||||
echo "=== Pod 로그: \$pod ==="
|
|
||||||
kubectl -n ${namespace} logs \$pod --tail=50 || echo "로그를 가져올 수 없습니다"
|
|
||||||
echo "=========================================="
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "=== Ingress 상태 확인 ==="
|
|
||||||
kubectl -n ${namespace} get ingress
|
|
||||||
kubectl -n ${namespace} describe ingress smarketing-backend || echo "Ingress를 찾을 수 없습니다"
|
|
||||||
|
|
||||||
echo "=== 서비스 Endpoint 확인 ==="
|
|
||||||
kubectl -n ${namespace} get endpoints
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
|
sh 'rm -rf manifest-repo || true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
301
smarketing-java/deployment/Jenkinsfile.backup
Normal file
301
smarketing-java/deployment/Jenkinsfile.backup
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
def PIPELINE_ID = "${env.BUILD_NUMBER}"
|
||||||
|
|
||||||
|
def getImageTag() {
|
||||||
|
def dateFormat = new java.text.SimpleDateFormat('yyyyMMddHHmmss')
|
||||||
|
def currentDate = new Date()
|
||||||
|
return dateFormat.format(currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
podTemplate(
|
||||||
|
label: "${PIPELINE_ID}",
|
||||||
|
serviceAccount: 'jenkins',
|
||||||
|
containers: [
|
||||||
|
containerTemplate(name: 'gradle', image: 'gradle:jdk17', ttyEnabled: true, command: 'cat'),
|
||||||
|
containerTemplate(name: 'docker', image: 'docker:20.10.16-dind', ttyEnabled: true, privileged: true),
|
||||||
|
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true),
|
||||||
|
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h')
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
emptyDirVolume(mountPath: '/home/gradle/.gradle', memory: false),
|
||||||
|
emptyDirVolume(mountPath: '/root/.azure', memory: false),
|
||||||
|
emptyDirVolume(mountPath: '/var/run', memory: false)
|
||||||
|
]
|
||||||
|
) {
|
||||||
|
node(PIPELINE_ID) {
|
||||||
|
def props
|
||||||
|
def imageTag = getImageTag()
|
||||||
|
def manifest = "deploy.yaml"
|
||||||
|
def namespace
|
||||||
|
def services = ['member', 'store', 'marketing-content', 'ai-recommend']
|
||||||
|
|
||||||
|
stage("Get Source") {
|
||||||
|
checkout scm
|
||||||
|
|
||||||
|
// smarketing-java 하위에 있는 설정 파일 읽기
|
||||||
|
props = readProperties file: "smarketing-java/deployment/deploy_env_vars"
|
||||||
|
namespace = "${props.namespace}"
|
||||||
|
|
||||||
|
echo "=== Build Information ==="
|
||||||
|
echo "Services: ${services}"
|
||||||
|
echo "Namespace: ${namespace}"
|
||||||
|
echo "Image Tag: ${imageTag}"
|
||||||
|
echo "Registry: ${props.registry}"
|
||||||
|
echo "Image Org: ${props.image_org}"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Check Changes") {
|
||||||
|
script {
|
||||||
|
def changes = sh(
|
||||||
|
script: "git diff --name-only HEAD~1 HEAD",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!changes.contains("smarketing-java/")) {
|
||||||
|
echo "No changes in smarketing-java, skipping build"
|
||||||
|
currentBuild.result = 'SUCCESS'
|
||||||
|
error("Stopping pipeline - no changes detected")
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Changes detected in smarketing-java, proceeding with build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("Setup AKS") {
|
||||||
|
container('azure-cli') {
|
||||||
|
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
||||||
|
sh """
|
||||||
|
echo "=== Azure 로그인 ==="
|
||||||
|
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
||||||
|
az account set --subscription 2513dd36-7978-48e3-9a7c-b221d4874f66
|
||||||
|
|
||||||
|
echo "=== AKS 인증정보 가져오기 (rg-digitalgarage-02) ==="
|
||||||
|
az aks get-credentials --resource-group rg-digitalgarage-02 --name aks-digitalgarage-02 --overwrite-existing
|
||||||
|
|
||||||
|
echo "=== 네임스페이스 생성 ==="
|
||||||
|
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
||||||
|
|
||||||
|
echo "=== Image Pull Secret 생성 ==="
|
||||||
|
kubectl create secret docker-registry acr-secret \\
|
||||||
|
--docker-server=${props.registry} \\
|
||||||
|
--docker-username=acrdigitalgarage02 \\
|
||||||
|
--docker-password=\$(az acr credential show --name acrdigitalgarage02 --query passwords[0].value -o tsv) \\
|
||||||
|
--namespace=${namespace} \\
|
||||||
|
--dry-run=client -o yaml | kubectl apply -f -
|
||||||
|
|
||||||
|
echo "=== 클러스터 상태 확인 ==="
|
||||||
|
kubectl get nodes
|
||||||
|
kubectl get ns ${namespace}
|
||||||
|
|
||||||
|
echo "=== 현재 연결된 클러스터 확인 ==="
|
||||||
|
kubectl config current-context
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Applications') {
|
||||||
|
container('gradle') {
|
||||||
|
sh """
|
||||||
|
echo "=== smarketing-java 디렉토리로 이동 ==="
|
||||||
|
cd smarketing-java
|
||||||
|
|
||||||
|
echo "=== gradlew 권한 설정 ==="
|
||||||
|
chmod +x gradlew
|
||||||
|
|
||||||
|
echo "=== 전체 서비스 빌드 ==="
|
||||||
|
./gradlew :member:clean :member:build -x test
|
||||||
|
./gradlew :store:clean :store:build -x test
|
||||||
|
./gradlew :marketing-content:clean :marketing-content:build -x test
|
||||||
|
./gradlew :ai-recommend:clean :ai-recommend:build -x test
|
||||||
|
|
||||||
|
echo "=== 빌드 결과 확인 ==="
|
||||||
|
find . -name "*.jar" -path "*/build/libs/*" | grep -v 'plain.jar'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build & Push Images') {
|
||||||
|
container('docker') {
|
||||||
|
sh """
|
||||||
|
echo "=== Docker 데몬 시작 대기 ==="
|
||||||
|
timeout 30 sh -c 'until docker info; do sleep 1; done'
|
||||||
|
"""
|
||||||
|
|
||||||
|
// ACR Credential을 Jenkins에서 직접 사용
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: 'acr-credentials',
|
||||||
|
usernameVariable: 'ACR_USERNAME',
|
||||||
|
passwordVariable: 'ACR_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "=== Docker로 ACR 로그인 ==="
|
||||||
|
echo "\$ACR_PASSWORD" | docker login ${props.registry} --username \$ACR_USERNAME --password-stdin
|
||||||
|
"""
|
||||||
|
|
||||||
|
services.each { service ->
|
||||||
|
script {
|
||||||
|
def buildDir = "smarketing-java/${service}"
|
||||||
|
def fullImageName = "${props.registry}/${props.image_org}/${service}:${imageTag}"
|
||||||
|
|
||||||
|
echo "Building image for ${service}: ${fullImageName}"
|
||||||
|
|
||||||
|
// 실제 JAR 파일명 동적 탐지
|
||||||
|
def actualJarFile = sh(
|
||||||
|
script: """
|
||||||
|
cd ${buildDir}/build/libs
|
||||||
|
ls *.jar | grep -v 'plain.jar' | head -1
|
||||||
|
""",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!actualJarFile) {
|
||||||
|
error "${service} JAR 파일을 찾을 수 없습니다"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "발견된 JAR 파일: ${actualJarFile}"
|
||||||
|
|
||||||
|
sh """
|
||||||
|
echo "=== ${service} 이미지 빌드 ==="
|
||||||
|
docker build \\
|
||||||
|
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \\
|
||||||
|
--build-arg ARTIFACTORY_FILE="${actualJarFile}" \\
|
||||||
|
-f smarketing-java/deployment/container/Dockerfile \\
|
||||||
|
-t ${fullImageName} .
|
||||||
|
|
||||||
|
echo "=== ${service} 이미지 푸시 ==="
|
||||||
|
docker push ${fullImageName}
|
||||||
|
|
||||||
|
echo "Successfully built and pushed: ${fullImageName}"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Generate & Apply Manifest') {
|
||||||
|
container('envsubst') {
|
||||||
|
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 replicas=${props.replicas}
|
||||||
|
|
||||||
|
# PostgreSQL 환경변수 추가 (올바른 DB명으로 수정)
|
||||||
|
export postgres_host='${props.POSTGRES_HOST}'
|
||||||
|
export postgres_port='5432'
|
||||||
|
export postgres_db_member='MemberDB'
|
||||||
|
export postgres_db_store='StoreDB'
|
||||||
|
export postgres_db_marketing_content='MarketingContentDB'
|
||||||
|
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}'
|
||||||
|
|
||||||
|
echo "=== 환경변수 확인 ==="
|
||||||
|
echo "namespace: \$namespace"
|
||||||
|
echo "postgres_host: \$postgres_host"
|
||||||
|
echo "postgres_port: \$postgres_port"
|
||||||
|
echo "postgres_user: \$postgres_user"
|
||||||
|
echo "postgres_db_member: \$postgres_db_member"
|
||||||
|
echo "postgres_db_store: \$postgres_db_store"
|
||||||
|
echo "postgres_db_marketing_content: \$postgres_db_marketing_content"
|
||||||
|
echo "postgres_db_ai_recommend: \$postgres_db_ai_recommend"
|
||||||
|
echo "redis_host: \$redis_host"
|
||||||
|
echo "redis_port: \$redis_port"
|
||||||
|
echo "replicas: \$replicas"
|
||||||
|
|
||||||
|
echo "=== Manifest 생성 ==="
|
||||||
|
envsubst < smarketing-java/deployment/${manifest}.template > smarketing-java/deployment/${manifest}
|
||||||
|
|
||||||
|
echo "=== Generated Manifest File ==="
|
||||||
|
cat smarketing-java/deployment/${manifest}
|
||||||
|
echo "==============================="
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
container('azure-cli') {
|
||||||
|
sh """
|
||||||
|
echo "=== 현재 연결된 클러스터 재확인 ==="
|
||||||
|
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 서비스를 찾을 수 없습니다."
|
||||||
|
|
||||||
|
echo "=== Redis 서비스 확인 ==="
|
||||||
|
kubectl get svc -n ${namespace} | grep redis || echo "Redis 서비스를 찾을 수 없습니다."
|
||||||
|
|
||||||
|
echo "=== Manifest 적용 ==="
|
||||||
|
kubectl apply -f smarketing-java/deployment/${manifest}
|
||||||
|
|
||||||
|
echo "=== 배포 상태 확인 (30초 대기) ==="
|
||||||
|
sleep 30
|
||||||
|
kubectl -n ${namespace} get deployments
|
||||||
|
kubectl -n ${namespace} get pods
|
||||||
|
|
||||||
|
echo "=== ConfigMap 확인 ==="
|
||||||
|
kubectl -n ${namespace} get configmap member-config -o yaml | grep -A 10 "data:"
|
||||||
|
kubectl -n ${namespace} get configmap ai-recommend-config -o yaml | grep -A 10 "data:"
|
||||||
|
|
||||||
|
echo "=== Secret 확인 ==="
|
||||||
|
kubectl -n ${namespace} get secret member-secret -o yaml | grep -A 5 "data:"
|
||||||
|
|
||||||
|
echo "=== 각 서비스 배포 대기 (120초 timeout) ==="
|
||||||
|
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/member --timeout=120s || echo "member deployment 대기 타임아웃"
|
||||||
|
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/store --timeout=120s || echo "store deployment 대기 타임아웃"
|
||||||
|
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/marketing-content --timeout=120s || echo "marketing-content deployment 대기 타임아웃"
|
||||||
|
timeout 120 kubectl -n ${namespace} wait --for=condition=available deployment/ai-recommend --timeout=120s || echo "ai-recommend deployment 대기 타임아웃"
|
||||||
|
|
||||||
|
echo "=== 최종 배포 상태 ==="
|
||||||
|
kubectl -n ${namespace} get all
|
||||||
|
|
||||||
|
echo "=== 각 서비스 Pod 로그 확인 (최근 20라인) ==="
|
||||||
|
for service in member store marketing-content ai-recommend; do
|
||||||
|
echo "=== \$service 서비스 로그 ==="
|
||||||
|
kubectl -n ${namespace} logs deployment/\$service --tail=20 || echo "\$service 로그를 가져올 수 없습니다"
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
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 -30
|
||||||
|
echo "=== Pod 로그: \$pod ==="
|
||||||
|
kubectl -n ${namespace} logs \$pod --tail=50 || echo "로그를 가져올 수 없습니다"
|
||||||
|
echo "=========================================="
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=== Ingress 상태 확인 ==="
|
||||||
|
kubectl -n ${namespace} get ingress
|
||||||
|
kubectl -n ${namespace} describe ingress smarketing-backend || echo "Ingress를 찾을 수 없습니다"
|
||||||
|
|
||||||
|
echo "=== 서비스 Endpoint 확인 ==="
|
||||||
|
kubectl -n ${namespace} get endpoints
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,3 +32,12 @@ POSTGRES_PASSWORD=DG_Won!
|
|||||||
REDIS_HOST=redis-digitalgarage-02.redis.cache.windows.net
|
REDIS_HOST=redis-digitalgarage-02.redis.cache.windows.net
|
||||||
REDIS_PASSWORD=bOpPbvYhUF8toxgHDfOJlG62HTtgX2AwxAzCaDajg2w=
|
REDIS_PASSWORD=bOpPbvYhUF8toxgHDfOJlG62HTtgX2AwxAzCaDajg2w=
|
||||||
REDIS_PORT=6380
|
REDIS_PORT=6380
|
||||||
|
|
||||||
|
# Azure Blob Storage 설정 (추가된 부분)
|
||||||
|
AZURE_STORAGE_ACCOUNT_NAME=stdigitalgarage02
|
||||||
|
AZURE_STORAGE_ACCOUNT_KEY=1cgMMGgonc5frC84eGM9bxgXYL7NtOUkzgCD/fH6MEnyo7O+bscMfVfmKQBfrvCC8/NnYGndZubm+AStZEDUpw==
|
||||||
|
AZURE_STORAGE_ENDPOINT=https://stdigitalgarage02.blob.core.windows.net
|
||||||
|
AZURE_STORAGE_CONTAINER_NAME=ai-content
|
||||||
|
AZURE_STORAGE_MENU_CONTAINER=smarketing-menu-images
|
||||||
|
AZURE_STORAGE_STORE_CONTAINER=smarketing-store-images
|
||||||
|
AZURE_STORAGE_MAX_FILE_SIZE=10485760
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import com.won.smarketing.member.dto.ValidationResponse;
|
|||||||
public interface MemberService {
|
public interface MemberService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 회원 등록
|
* 회원 등록
|
||||||
*
|
*
|
||||||
* @param request 회원가입 요청 정보
|
* @param request 회원가입 요청 정보
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user