Kubernetes AutoScaling prerequisites¶
AutoScaling in Kubernetes requires the cluster to have access to accurate and up-to-date resource usage data. Since the core Kubernetes platform does not inherently provide a mechanism to store or expose these Metrics, an external aggregation tool must be deployed^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md].
Metrics Server¶
The Metrics Server is the standard, cluster-level aggregator used to collect and expose resource metrics^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]. It functions by:
- Collecting Data: It gathers Metrics from the
kubeleton each node, including CPU and Memory usage^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]. - Serving APIs: It registers as an API server (typically via
kube-aggregator) at/apis/[Metrics](<./metrics.md>).k8s.ioto expose this data to the cluster^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]. - In-Memory Storage: Data is stored only in memory, meaning historical data is lost if the server restarts^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md].
Installation Considerations¶
Depending on the Kubernetes environment, the Metrics Server may not be installed by default (e.g., it is missing in standard Docker-Desktop Kubernetes environments)^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md].
When installing the Metrics Server, specific configurations may be required for it to communicate successfully with the kubelet:
- Insecure TLS: In local or testing environments without proper Certificate Authority (CA) setup, the deployment arguments must include
--kubelet-insecure-tlsto skip certificate verification^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]. - Address Types: It is often necessary to configure
--kubelet-preferred-address-typesto ensure the server can correctly resolve the node's IP address^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md].
Verification¶
Once installed and running, the availability of Metrics can be verified using the kubectl top command^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]. This confirms that the prerequisites for Horizontal Pod Autoscaler or other autoscaling mechanisms are met.
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day24__README.md]