In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Resource metrics pipeline:
Starting with Kubernetes 1.8, resource usage metrics, such as container CPU and memory usage, are available in Kubernetes through Metrics API. These metrics can be accessed directly by users, such as using the kubectl top command line, or used by controllers in the cluster, such as Horizontal Pod Autoscaler, to make decisions; Metrics API:
With Metrics API, you can get the amount of resources currently used by a specified node or pod. This API does not store indicator values, so it is impossible to obtain the resource usage of a specified node 10 minutes ago. Metrics API repository:
API source code GitHub warehouse address: Metrics Server:
Metrics Server is a kind of API Server. It provides the core Metrics API, which collects indicator information through the Metrics Server Kubernetes aggregator registered in the main API server, just as the K8s component kube-apiserver provides many API groups, but it is not a part of K8s, but a single Pod running on K8s.
In order to allow users to seamlessly use the API in Metrics Server, you also need to aggregate this custom API into the core API group through the aggregator, and then treat this API as part of the core API and view it directly through kubectl api-versions.
Metrics Server collects metrics data from Summary API, port 10250, provided by kubelet on each node, collects Node and Pod core resource metrics data, mainly memory and cpu usage, and stores the collected information in memory; you need to deploy it, otherwise it will not be available in the cluster
Metrics API needs to deploy Metrics Server in the cluster. Otherwise it will not be available
Deploy Metrics API (Metrics Server) in a Kubernetes cluster
K8s new generation architecture
Core metrics pipeline: composed of api provided by kubelet, metrics-server and api-server, statistics of cpu cumulative utilization, real-time memory utilization, Pod resource utilization and container disk utilization
Monitoring pipeline: used to collect various indicator data from the system and provide end users, storage systems and HPA, which contain core indicators and many non-core indicators. Non-core indicators themselves cannot be parsed by k8s; deployment manual reference
I deploy the official site of the metrics-server reference to download the yaml files needed to deploy metrics server from the official site.
Use the for loop to download [root@node1 metrics] # lltotal 24 Feb RW Feb 28 03:30 auth-delegator.yaml-rw-r--r-- 1 root root 419 Feb 28 03:30 auth-reader.yaml-rw-r--r-- 1 root root 388 Feb 28 03:30 metrics-apiservice.yaml-rw-r--r-- 1 root root 3252 Feb 28 03:30 metrics-server-deployment.yaml-rw-r--r-- 1 Root root 336 Feb 28 03:30 metrics-server-service.yaml-rw-r--r-- 1 root root 795 Feb 28 03:30 resource-reader.yaml [root@node1 metrics] # modify the metrics-server-deployment.yaml file
Modify the custom variable resource limit in the container, otherwise you cannot running;command: / / modify-/ metrics-server-metric-resolution=30s # These are needed for GKE, which doesn't support secure communication yet. # Remove these lines for non-GKE clusters, and when GKE supports token-based auth. -kubelet-port=10250 #-deprecated-kubelet-completely-insecure=true-kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS ExternalIPcommand: / / modify here-/ pod_nanny-config-dir=/etc/config-cpu=5m-extra-cpu=0.5m-memory=80Mi-extra-memory=8Mi-- threshold=5-deployment=metrics-server-v0.3.6-container=metrics-server-- poll-period=300000-estimator=exponential # Specifies the smallest cluster (defined In number of nodes) # resources will be scaled to. #-minClusterSize= {{metrics_server_min_cluster_size}} modify the resource-reader.yaml file
Add nodes/statsrules:- apiGroups:-"" resources:-pods-nodes-namespaces-nodes/stats to download the image file in advance on each node node
Refer to script [root@node2 ~] # cat pull-metrics.sh #! / bin/bash#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6 k8s.gcr.io/metrics-server-amd64:v0.3.6docker tag registry .cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7 k8s.gcr.io/addon-resizer:1.8.7docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.6docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.8.7 [root@node2 ~] # Metrics Server application construction
Cannot be repeated to build [root@node1 metrics] # kubectl apply-f. / clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator createdrolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader createdapiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io createdserviceaccount/metrics-server createdconfigmap/metrics-server-config createddeployment.apps/metrics-server-v0.3.6 createdservice/metrics-server createdclusterrole.rbac.authorization.k8s.io/system:metrics-server createdclusterrolebinding.rbac.authorization .k8s.io/system:metrics-server created [root@node1 metrics] # [root@node1 ~] # kubectl get pods-n kube-systemNAME READY STATUS RESTARTS AGEmetrics-server-v0.3.6-cf56dfd4-mj7p2 2 + 2 Running 0 22s test waiting for results
Sometimes you have to wait a while before you can brush out the data [root@node1 ~] # kubectl top nodesNAME CPU (cores) CPU% MEMORY (bytes) MEMORY% node1 137m 6 1043Mi 69% node2 21m 2% 333Mi 20% node3 23m 2% 343Mi 28% access the node resource information path through the interface
View node resource metrics
[root@node1 metrics] # kubectl get-- raw "/ apis/metrics.k8s.io/v1beta1/nodes" | jq | less
View pods resource metrics
[root@node1 metrics] # kubectl get-- raw "/ apis/metrics.k8s.io/v1beta1/pods" | jq | less
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.