Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install the kubectl top plug-in

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Brief introduction

Kubectl is a tool that, like etcdctl, does not have to be installed. Each node communicates with the management node through api-server. Api-server can be deployed on any node, and so can kube-proxy, which is a separate component.

Kubectl top can easily view the real-time resource usage of node and pod, such as CPU and memory.

Realization principle

Scheduling components such as kubectl top, K8s dashboard, and HPA use the same data, with the following data links:

When using heapster: apiserver will directly forward the metric request to the hepaster service in the cluster through proxy.

When using metrics-server: apiserver accesses metric through the address of / apis/metrics.k8s.io/

Here you can compare the logs of kubect get pod:

1. Download the yaml file wget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/auth-delegator.yamlwget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/metrics-server-service.yamlwget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/auth-reader.yamlwget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/metrics-apiservice.yamlwget http://pencil-file.oss-cn- Hangzhou.aliyuncs.com/blog/metrics-server-deployment.yamlwget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/aggregated-metrics-reader.yamlwget http://pencil-file.oss-cn-hangzhou.aliyuncs.com/blog/resource-reader.yaml2. Modify the metrics-server-deployment.yaml file

Core configuration:

Containers:-name: metrics-server image: k8s.gcr.io/metrics-server-amd64:v0.3.2 imagePullPolicy: IfNotPresent # modified to local image priority use command:-/ metrics-server- metric-resolution=30s-kubelet-insecure-tls-kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS ExternalIP # container default script volumeMounts:-name: tmp-dir mountPath: / tmp3. Pull the image

Docker pull k8s.gcr.io/metrics-server-amd64

Since the image is abroad, it is possible to use other ways to surf the Internet or import it locally.

Surrogate method

Mkdir-p / etc/systemd/system/docker.service.d# creates a folder to put agents. By default, there is no configuration for echo'[Service] Environment= "HTTP_PROXY=192.168.0.26:8118"HTTPS_PROXY=192.168.0.26:8118" > / etc/systemd/system/docker.service.d/http-proxy.conf# to create agents, provided that systemctl daemon-reloadsystemctl restart docker#, a proxy server that can access foreign mirror servers, restarts docker.

If you run the above script, you can pull the image abroad.

Local export import method

First go to the host that has been pulled and exported.

Docker save-o metrics-server-amd64:v0.3.2.tar k8s.gcr.io/metrics-server-amd64:v0.3.2

# .tar is a completed packaged file. The image name to be exported needs to be accompanied by the version name, which can be viewed by docker images.

Import

Docker load

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report