Home > Blog > tech

HPA Custom Metrics คืออะไร? Autoscaling K8s ด้วย Prometheus Metrics 2026

HPA Custom Metrics คืออะไร? Autoscaling K8s ด้วย Prometheus Metrics 2026
2026-04-16 | tech | 3400 words

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


Back to Blog | iCafe Forex | SiamLanCard | Siam2R