반응형
목적
Spring Boot 기반 로그 출력 앱을 Azure Kubernetes Service에 배포하고, Helm + Kustomize + ArgoCD 기반으로 GitOps 테스트를 수행합니다.
애플리케이션은 일정 횟수만 로그 출력 후 자동 종료되므로 Deployment가 아닌 Job으로 배포합니다.
Step 1: Maven으로 JAR 빌드
Dockerfile이 JAR 파일을 필요로 하므로, 먼저 Maven으로 애플리케이션을 빌드해야 합니다.
# Java 8 이상을 지원하도록 pom.xml 수정
vi pom.xml
# 아래처럼 수정
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
# Maven 빌드 실행
mvn clean package
결과 : target/kubepia-kubepia.jar 생성
Step 2: Docker 이미지 빌드
AKS에 배포할 수 있도록 .jar 파일을 포함한 Docker 이미지가 필요합니다.
Dockerfile
FROM openjdk:8-jdk-alpine
ADD target/*.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-cp","/app.jar", "net.kubepia.app.App"]
docker buildx build --platform linux/amd64 -t test-logger:latest .
Step 3: Azure ACR에 이미지 Push
AKS는 Azure Container Registry(ACR)에 저장된 이미지를 pull하여 배포합니다.
ACR 이름 확인
az acr list -o table

Image Tag & Push
# ACR 로그인
az acr login --name acrcloudbizcomapp01
# 이미지 태그 변경
docker tag test-logger:latest acrcloudbizcomapp01.azurecr.io/test-logger:latest
# 이미지 Push
docker push acrcloudbizcomapp01.azurecr.io/test-logger:latest
Step 4: AKS와 ACR 권한 연결
AKS 클러스터가 ACR에서 이미지를 pull할 수 있도록 권한을 부여합니다.
az aks update \
--name aks-cloudbiz-dev-cloudcoe \
--resource-group rg-cloudbiz-dev-ccoe \
--attach-acr acrcloudbizcomapp01
Step 5: 로그 테스트 앱 배포
Spring Boot 기반 로그 발생 애플리케이션 kloudbank/test-logger를 Azure AKS 클러스터에 Job 형태로 배포하여, 로그 수집 테스트를 위한 단발성 로그 출력 환경을 구축합니다.
GitOps 기반 관리도 가능하도록 Kustomize + ArgoCD 구성도 포함합니다.
디렉토리 구조
helm-kustomize-ktds/
└── clusters/
└── aks-cloudbiz-dev-cloudcoe/
└── test-logger/
├── job.yaml
├── namespaces.yaml
└── kustomization.yaml
1. job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: test-logger
namespace: test-logger
labels:
app: test-logger
spec:
template:
metadata:
labels:
app: test-logger
spec:
containers:
- name: test-logger
image: acrcloudbizcomapp01.azurecr.io/test-logger:latest
imagePullPolicy: IfNotPresent
env:
- name: PORT
value: "8080"
- name: RUN_COUNT
value: "10"
- name: RUN_SLEEP
value: "1000"
restartPolicy: Never
결과 확인
# Job 실행 상태 확인
kubectl get jobs -n test-logger
# 파드 로그 확인 (로그 출력 확인)
kubectl logs job/test-logger -n test-logger
~ kubectl get jobs -n test-logger
NAME COMPLETIONS DURATION AGE
test-logger 1/1 13s 3m5s
➜ ~ kubectl logs job/test-logger -n test-logger
2025-04-09 06:16:12.495 [count: 0]-Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
2025-04-09 06:16:13.504 [count: 1]-Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
2025-04-09 06:16:14.505 [count: 2]-Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
형태 | 단발성 Job |
환경변수 | RUN_COUNT, RUN_SLEEP 사용 |
목적 | Loki + Promtail 로그 수집 테스트 등 |
GitOps 관리 | Kustomize + ArgoCD로 자동 관리 가능 |
반응형
'Kubernetes' 카테고리의 다른 글
AKS 환경에서 Promtail → Loki → Grafana 기반 로그 수집 (0) | 2025.04.14 |
---|---|
AKS 기반 Promtail-Loki-Grafana 로그 수집 시스템 구축 및 테스트 (0) | 2025.04.10 |
AKS에서 Bookinfo 앱을 활용한 Ingress Add-on 및 Topology Spread Constraints (0) | 2025.04.02 |
Helm 기반 Jenkins 설치 시 InitContainer 실패 원인 분석 및 해결 (0) | 2025.04.01 |
k6 + Grafana + Prometheus로 성능 테스트 환경 구축 및 시각화 (0) | 2025.01.17 |