You can create a HPA to any custom metrics available in your node following the guide from official docs.
In order to get the APIs available for you, metrics-server exposes metrics via APIs below:
/nodes - all node metrics; type []NodeMetrics
/nodes/{node} - metrics for a specified node; type NodeMetrics
/namespaces/{namespace}/pods - all pod metrics within namespace with support for all-namespaces; type []PodMetrics
/namespaces/{namespace}/pods/{pod} - metrics for a specified pod; type PodMetrics
Full command to list available APIs looks like:
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
In case you are working on GCP or other cloud, there is a guide for Deploying the Custom Metrics in GCP
UPDATE
Answering to your comments:
HPA able to read metrics from:
- metrics.k8s.io (resource metrics)
- custom.metrics.k8s.io(custom metrics)
- external.metrics.k8s.io(external metrics)
The common use for HorizontalPodAutoscaler is to configure it to fetch metrics from aggregated APIs (metrics.k8s.io, custom.metrics.k8s.io, or external.metrics.k8s.io). The metrics.k8s.io API is usually provided by an add on named Metrics Server, which needs to be launched separately. For more information about resource metrics, see Metrics Server.
So, you can take anything from metrics.k8s.io that is available to your cluster. Or you can create your own APIService:
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: <name of the registration object>
spec:
group: <API group name this extension apiserver hosts>
version: <API version this extension apiserver hosts>
groupPriorityMinimum: <priority this APIService for this group, see API documentation>
versionPriority: <prioritizes ordering of this version within a group, see API documentation>
service:
namespace: <namespace of the extension apiserver service>
name: <name of the extension apiserver service>
caBundle: <pem encoded ca cert that signs the server cert used by the webhook>
Please find a full guide on creating your APIService. Have fun :)