Jenkins CI/CD 파이프라인 완전 구축 및 가이드 개선

- Kustomize 기반 환경별 매니페스트 구조 생성
  - Base: 공통 리소스 및 네임스페이스 설정
  - Overlays: dev/staging/prod 환경별 설정
  - Patch: 환경별 replicas, resources, 도메인 설정

- Jenkins 파이프라인 구축
  - 완전한 Jenkinsfile 작성 (빌드, 테스트, 배포)
  - SonarQube 품질 분석 및 Quality Gate 적용
  - ACR 이미지 빌드 및 푸시 자동화
  - AKS 배포 자동화

- 환경별 설정 관리
  - dev: 1 replica, 기본 리소스, HTTP
  - staging: 2 replicas, 중간 리소스, HTTPS
  - prod: 3 replicas, 고사양 리소스, HTTPS, 보안 강화

- 배포 자동화 도구
  - 수동 배포 스크립트 작성 및 실행 권한 설정
  - 롤백 방법 및 트러블슈팅 가이드 포함

- 완전한 구축 가이드 문서 작성
  - Jenkins 환경 설정 방법
  - Credentials 등록 방법
  - Pipeline Job 생성 방법
  - 배포 실행 및 모니터링 방법
  - 체크리스트 및 트러블슈팅 가이드

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hiondal
2025-09-12 13:23:13 +09:00
parent 042198deb0
commit c7e5a86de8
29 changed files with 382 additions and 484 deletions
+38 -23
View File
@@ -11,8 +11,22 @@ podTemplate(
serviceAccount: 'jenkins',
containers: [
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
containerTemplate(name: 'gradle', image: 'gradle:jdk17', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true)
containerTemplate(name: 'gradle',
image: 'gradle:jdk17',
ttyEnabled: true,
command: 'cat',
envVars: [
envVar(key: 'DOCKER_HOST', value: 'unix:///run/podman/podman.sock'),
envVar(key: 'TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE', value: '/run/podman/podman.sock'),
envVar(key: 'TESTCONTAINERS_RYUK_DISABLED', value: '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: '/run/podman', memory: false)
]
) {
node(PIPELINE_ID) {
@@ -48,23 +62,38 @@ podTemplate(
# 각 서비스별 테스트 및 분석
./gradlew :api-gateway:test :api-gateway:jacocoTestReport :api-gateway:sonar \\
-Dsonar.projectKey=phonebill-api-gateway-\${environment} \\
-Dsonar.projectName=phonebill-api-gateway
-Dsonar.projectName=phonebill-api-gateway \\
-Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
./gradlew :user-service:test :user-service:jacocoTestReport :user-service:sonar \\
-Dsonar.projectKey=phonebill-user-service-\${environment} \\
-Dsonar.projectName=phonebill-user-service
-Dsonar.projectName=phonebill-user-service \\
-Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
./gradlew :bill-service:test :bill-service:jacocoTestReport :bill-service:sonar \\
-Dsonar.projectKey=phonebill-bill-service-\${environment} \\
-Dsonar.projectName=phonebill-bill-service
-Dsonar.projectName=phonebill-bill-service \\
-Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
./gradlew :product-service:test :product-service:jacocoTestReport :product-service:sonar \\
-Dsonar.projectKey=phonebill-product-service-\${environment} \\
-Dsonar.projectName=phonebill-product-service
-Dsonar.projectName=phonebill-product-service \\
-Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
./gradlew :kos-mock:test :kos-mock:jacocoTestReport :kos-mock:sonar \\
-Dsonar.projectKey=phonebill-kos-mock-\${environment} \\
-Dsonar.projectName=phonebill-kos-mock
-Dsonar.projectName=phonebill-kos-mock \\
-Dsonar.java.binaries=build/classes/java/main \\
-Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml \\
-Dsonar.exclusions=**/config/**,**/entity/**,**/dto/**,**/*Application.class,**/exception/**
"""
}
}
@@ -93,7 +122,7 @@ podTemplate(
podman build \\
--build-arg BUILD_LIB_DIR="\${service}/build/libs" \\
--build-arg ARTIFACTORY_FILE="\${service}.jar" \\
-f deployment/container/Dockerfile \\
-f deployment/container/Dockerfile-backend \\
-t acrdigitalgarage01.azurecr.io/phonebill/\${service}:\${environment}-\${imageTag} .
podman push acrdigitalgarage01.azurecr.io/phonebill/\${service}:\${environment}-\${imageTag}
@@ -132,19 +161,5 @@ podTemplate(
"""
}
}
stage('Health Check') {
container('azure-cli') {
sh """
echo "🔍 Health Check starting..."
# API Gateway Health Check
GATEWAY_POD=\$(kubectl get pod -n phonebill-\${environment} -l app=api-gateway -o jsonpath='{.items[0].metadata.name}')
kubectl -n phonebill-\${environment} exec \$GATEWAY_POD -- curl -f http://localhost:8080/actuator/health || exit 1
echo "✅ All services are healthy!"
"""
}
}
}
}