티스토리 뷰
728x90
🎯 목적: 커스텀 SMT JAR을 PVC(영속 볼륨)에 저장하여 Kafka Connect에서 플러그인으로 자동 로딩
🗂️ 전체 디렉토리 구성 예시
kafka-connect-gitops/
├── helm/
│ └── kafka-connect-values.yaml
├── connectors/
│ ├── my-source.json
│ └── ...
├── smt/
│ └── custom-smt/
│ └── src/main/java/com/example/CustomSMT.java
├── plugins/
│ └── kafka-connect-custom-smt.jar ← 여기서 빌드됨
├── scripts/
│ ├── build-smt.sh
│ └── copy-jar-to-pvc.sh ← 이게 핵심
├── .gitlab-ci.yml
🔧 1. Kafka Connect Helm values.yaml (PVC 마운트 설정)
pluginPaths: "/opt/kafka/plugins,/opt/kafka/custom-smt"
extraVolumeMounts:
- name: custom-smt-volume
mountPath: /opt/kafka/custom-smt
extraVolumes:
- name: custom-smt-volume
persistentVolumeClaim:
claimName: kafka-custom-smt-pvc
📦 2. PVC 생성 (사전 작업)
# pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: kafka-custom-smt-pvc
namespace: kafka
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
kubectl apply -f pvc.yaml
💡 NFS 같은 RWX 지원 스토리지 클래스 필요합니다 (ReadWriteMany)
🛠️ 3. SMT 빌드 스크립트 (build-smt.sh)
#!/bin/bash
cd smt
./gradlew clean shadowJar
JAR_PATH=$(find . -name "*.jar" | grep build/libs)
cp "$JAR_PATH" ../plugins/kafka-connect-custom-smt.jar
echo "✅ SMT JAR 빌드 완료 → plugins/"
📁 4. PVC에 SMT JAR 복사 (copy-jar-to-pvc.sh)
#!/bin/bash
# PVC를 사용하는 pod 임시 생성 (PVC 마운트용)
kubectl run pvc-uploader --image=alpine --restart=Never \
--overrides='{
"spec": {
"containers": [{
"name": "uploader",
"image": "alpine",
"command": ["sleep", "3600"],
"volumeMounts": [{
"mountPath": "/mnt",
"name": "smt-volume"
}]
}],
"volumes": [{
"name": "smt-volume",
"persistentVolumeClaim": {
"claimName": "kafka-custom-smt-pvc"
}
}]
}
}'
# 잠시 대기 후 SMT JAR 복사
sleep 5
kubectl cp plugins/kafka-connect-custom-smt.jar pvc-uploader:/mnt/
# Pod 삭제
kubectl delete pod pvc-uploader
🚀 5. CI/CD 통합 (.gitlab-ci.yml 예시)
stages:
- build
- deploy
build-smt:
stage: build
image: gradle:8-jdk17
script:
- chmod +x scripts/build-smt.sh
- ./scripts/build-smt.sh
artifacts:
paths:
- plugins/kafka-connect-custom-smt.jar
deploy-smt-pvc:
stage: deploy
image: bitnami/kubectl:latest
script:
- chmod +x scripts/copy-jar-to-pvc.sh
- ./scripts/copy-jar-to-pvc.sh
- kubectl rollout restart deployment kafka-connect -n kafka
only:
- main
728x90
'CI_CD' 카테고리의 다른 글
Kafka Connect 커스텀 SMT 배포 방식 비교표 (0) | 2025.04.18 |
---|---|
Kafka Connect + 커스텀 SMT GitOps 통합 관리 전략 (InitContainer) (0) | 2025.04.18 |
Kafka Connect + 커스텀 SMT GitOps 통합 관리 전략 (ConfigMap) (0) | 2025.04.18 |
Kafka Connect SMT 멀티레포 + Git Submodule + 개별/통합 빌드 (0) | 2025.04.16 |
CI/CD 자동화 다이어그램/시퀀스 다이어그램 (0) | 2025.04.06 |