Kubernetes에서 Camel이 잘 동작하는 이유
Camel의 컴포넌트 기반 아키텍처와 Kubernetes의 컨테이너 오케스트레이션은 잘 맞습니다. Camel 애플리케이션은 상태를 외부 시스템(DB, 메시지 큐)에 저장하면 완전히 스테이트리스하게 만들 수 있어 수평 확장이 쉽습니다.
Kubernetes 배포 매니페스트
apiVersion: apps/v1
kind: Deployment
metadata:
name: camel-order-processor
spec:
replicas: 3
selector:
matchLabels:
app: camel-order-processor
template:
spec:
containers:
- name: camel-app
image: myregistry/camel-order-processor:1.0.0
ports:
- containerPort: 8080
env:
- name: BROKER_URL
valueFrom:
secretKeyRef:
name: broker-secret
key: url
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 10
HPA로 자동 스케일링
메시지 처리량에 따라 Camel 인스턴스를 자동으로 늘리거나 줄일 수 있습니다.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: camel-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: camel-order-processor
minReplicas: 2
maxReplicas: 20
metrics:
- type: External
external:
metric:
name: activemq_queue_size
selector:
matchLabels:
queue: orders
target:
type: AverageValue
averageValue: "100" # 큐에 100개 이상이면 스케일 업
Camel K – Kubernetes Native Camel
Camel K는 Kubernetes 전용으로 설계된 경량 Camel 실행 환경입니다. 라우트 파일만 Kubernetes에 올리면 자동으로 컨테이너를 빌드하고 배포합니다.
# routes.java 파일만 만들면 끝
kamel run routes.java
# 자동으로 빌드, 컨테이너화, 배포까지 처리
# watch 모드로 코드 변경 즉시 반영
kamel run routes.java --dev
Prometheus + Grafana 모니터링
Camel Spring Boot는 Micrometer를 통해 Prometheus 메트릭을 자동으로 노출합니다.
# application.properties
management.endpoints.web.exposure.include=prometheus,health
management.metrics.export.prometheus.enabled=true
# 주요 Camel 메트릭
# camel_routes_running_routes - 실행 중인 라우트 수
# camel_exchanges_total - 총 처리 메시지 수
# camel_exchanges_failed_total - 실패 메시지 수
# camel_route_processing_time_seconds - 처리 시간
Grafana 대시보드에서 이 메트릭을 시각화하면 각 라우트의 처리량, 오류율, 지연 시간을 실시간으로 모니터링할 수 있습니다. 임계값을 설정해 PagerDuty나 Slack으로 알림을 받을 수도 있습니다.
ConfigMap으로 설정 동적 변경
apiVersion: v1
kind: ConfigMap
metadata:
name: camel-config
data:
application.properties: |
camel.route.throttle=100
camel.route.batch-size=50
# Pod에 마운트
volumes:
- name: config-volume
configMap:
name: camel-config
volumeMounts:
- name: config-volume
mountPath: /app/config