In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how Kubernetes HPA Controller works". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How HPA Controller works
K8s automatically scales the pods managed by rc and deployment based on the acquired metrics (CPU utilization, custom metrics) value through HPA.
As of the Kubernetes 1.6 release feature, only CPU utilization is supported as a resource metrics, and the support for custom metrics is still in the alpha stage.
HPA Controller periodically (once every 30s by default, which can be set through the flag--horizontal-pod-autoscaler-sync-period of kube-controller-manager). Adjust the number of replicas in the corresponding rc and deployment, so that the specified metrics value can match the target utilization value specified by the user.
In each HPA Controller processing cycle, kube-controller-manager queries the utilization of the metrics defined in the HPA. The query method varies depending on the metric type:
If metric type is resource metrics, query through resource metrics API.
If metric type belongs to custom metrics, it is queried through custom metrics API.
Calculate the scaling algorithm:
For resource metrics, for example, if CPU,HPA Controller acquires the metrics specified in HPA, if target utilization is set in HPA, HPA Controller will divide the acquired metrics by the resource request value of the corresponding container as the resource utilization of the detected current pod. After calculating the pods corresponding to all the HPA, take the average of the resource utilization values. Finally, the average value is divided by the defined target utilization to get the scaling ratio.
Note: if the containers in some pods corresponding to HPA do not define the corresponding resource request, HPA will not scale those pods.
The scaling algorithm for custome metrics,HPA Controller is almost the same as resource metrics, except that it is calculated based on the metrics value queried by custome metrics API versus target metics value, rather than by utilization.
The relationship between HPA and rc, deployment, and pod is shown in the following figure.
HPA controls the replicas of RC and Deployment through Scale sub-resource interface.
After all, HPA controls the number of Pod copies through RC and Deployment controllers.
HPA Controller can obtain metrics in two ways:
Direct Heapster access: for monitoring resource metrics, you need to deploy Heapster in kube-system namespace in advance.
REST client access: for monitoring custom metrics, you need to set the-horizontal-pod-autoscaler-use-rest-clients flag of kube-controller-manager to true.
This is the end of the introduction to how Kubernetes HPA Controller works. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.