horizontal pod autoscaling可以根据cpu使用率或自定应metrics自动扩展pod,支持(rs,deployment) 控制器每隔30s(可以通过--horizontal-pod-autoscaler-sync-period 修改)查询metrics的资源使用情况 支持三种metrics类型 预定义metrics(比如 Pod 的 CPU)以利用率的方式计算 自定义的pod metrics,以原始值(raw value)的方式计算 自定义的object metrics 支持两种metrics的查询方式:heapster和自定义的RESTful API 支持多metrics 使用hpa之前需要确保已部署好metrics-server ``` ## 创建pod与service kubectl run php --image=php --requests=cpu=200m --expose --port=80 ## 创建autoscaler kubectl autoscale deployment php --cpu-percent=50 --min=1 --max=10 ```