HPA (Horizontal Pod Autoscaler) ช่วย Scale Pod อัตโนมัติ Default ใช้ CPU/Memory แต่ Production ต้องการ Custom Metrics จาก Prometheus
HPA Architecture
# Architecture:
# App -> Prometheus -> Prometheus Adapter -> K8s Custom Metrics API -> HPA
#
# ติดตั้ง Prometheus Adapter ด้วย Helm:
# helm install prometheus-adapter prometheus-community/prometheus-adapter
#
# HPA Custom Metric (requests per second):
# apiVersion: autoscaling/v2
# kind: HorizontalPodAutoscaler
# spec:
# metrics:
# - type: Pods
# pods:
# metric:
# name: http_requests_per_second
# target:
# type: AverageValue
# averageValue: "100"
#
# KEDA = Alternative ที่ Scale to Zero ได้
# รองรับ Event Sources มากกว่า HPA
สรุป
HPA Custom Metrics ช่วยให้ Scale Pod ตาม Business Metrics จริง ไม่ใช่แค่ CPU/Memory ใช้ Prometheus Adapter หรือ KEDA สำหรับ Custom Metrics
