How to set up a horizontal autoscaler for pods on a physical server?
sobes.tech AI
Answer from AI
To set up horizontal autoscaling (Horizontal Pod Autoscaler, HPA) on a physical server (bare-metal) in Kubernetes, you need to follow several steps:
-
Ensure that the Metrics Server is configured in the cluster — it collects CPU and memory metrics necessary for HPA to function.
-
Configure resource monitoring for pods and nodes — without cloud infrastructure, you should use local solutions, such as Prometheus with HPA adapters.
-
Create an HPA object, specifying target metrics and minimum/maximum replica counts. For example:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: example-deployment
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
-
Ensure the HPA controller and metrics are working correctly — on bare-metal, additional configuration of RBAC and network policies may be required.
-
Test autoscaling under load and monitor behavior.
Important: on a physical server, there are no cloud APIs for scaling, so HPA only works at the pod level, and node scaling must be done manually or with other tools.