首页 > 其他分享 >安装 Metrics server

安装 Metrics server

时间:2022-10-11 13:03:50浏览次数:87  
标签:metrics -- com server Metrics io k8s 安装

安装 Metrics server

Metrics Server 是 Kubernetes 内置自动缩放管道的可扩展、高效的容器资源指标来源。

Metrics Server 从 Kubelets 收集资源指标,并通过Metrics API在 Kubernetes apiserver 中公开它们,以供 Horizontal Pod Autoscaler和Vertical Pod Autoscaler使用。Metrics API 也可以通过 访问kubectl top,从而更容易调试自动缩放管道。

单机版


单机版
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

查看镜像地址
grep -rn image components.yaml
140: image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
141: imagePullPolicy: IfNotPresent

设置镜像地址为阿里云
sed -i "s#k8s.gcr.io/metrics-server#registry.cn-hangzhou.aliyuncs.com/chenby#g" components.yaml

查看镜像地址已更新
grep -rn image components.yaml
140: image: registry.cn-hangzhou.aliyuncs.com/chenby/metrics-server:v0.6.1
141: imagePullPolicy: IfNotPresent

args添加tls证书配置选项
vim components.yaml

添加"- --kubelet-insecure-tls"

例:
args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
- --kubelet-insecure-tls
image: registry.cn-hangzhou.aliyuncs.com/chenby/metrics-server:v0.6.1

执行配置
kubectl apply -f components.yaml
serviceaccount/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
service/metrics-server created
deployment.apps/metrics-server created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

高可用版本


高可用版本
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability.yaml

查看镜像地址
grep -rn image high-availability.yaml
150: image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
151: imagePullPolicy: IfNotPresent

设置镜像地址为阿里云
sed -i "s#k8s.gcr.io/metrics-server#registry.cn-hangzhou.aliyuncs.com/chenby#g" high-availability.yaml

查看镜像地址已更新
grep -rn image high-availability.yaml
150: image: registry.cn-hangzhou.aliyuncs.com/chenby/metrics-server:v0.6.1
151: imagePullPolicy: IfNotPresent

args添加tls证书配置选项
vim high-availability.yaml

添加"- --kubelet-insecure-tls"

例:
args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
- --kubelet-insecure-tls
image: registry.cn-hangzhou.aliyuncs.com/chenby/metrics-server:v0.6.1

执行配置
kubectl apply -f high-availability.yaml
serviceaccount/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
service/metrics-server created
deployment.apps/metrics-server created
Warning: policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget
poddisruptionbudget.policy/metrics-server created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

验证


查看metrics资源
kubectl get pod -n kube-system | grep metrics
metrics-server-65fb95948b-2bcht 1/1 Running 0 32s
metrics-server-65fb95948b-vqp5s 1/1 Running 0 32s

查看node资源情况
kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k8s-master01 127m 1% 2439Mi 64%
k8s-node01 50m 0% 1825Mi 23%
k8s-node02 53m 0% 1264Mi 16%

查看pod资源情况
kubectl top pod
NAME CPU(cores) MEMORY(bytes)
chenby-57479d5997-44926 0m 10Mi
chenby-57479d5997-tbpqc 0m 11Mi
chenby-57479d5997-w8cp2 0m 6Mi

​https://www.oiox.cn/​​​https:/blog.oiox.cn/
https://www.chenby.cn/
https://cby-chen.github.io/
https://www.zhihu.com/people/chen-bu-yun-2
https://cloud.tencent.com/developer/column/93230https://www.jianshu.com/u/0f894314ae2chttps://www.toutiao.com/c/user/token/MS4wLjABAAAAeqOrhjsoRZSj7iBJbjLJyMwYT5D0mLOgCoo4pEmpr4A/、GitHub、知乎、思否、简书、腾讯云、今日头条、个人博客、全网可搜《小陈运维》
文章主要发布于微信公众号:《Linux运维交流社区》



标签:metrics,--,com,server,Metrics,io,k8s,安装
From: https://blog.51cto.com/u_12212643/5746151

相关文章

  • 二进制安装Kubernetes(k8s)IPv4/IPv6双栈 v1.24.0
    二进制安装Kubernetes(k8s)v1.24.0IPv4/IPv6双栈介绍kubernetes二进制安装1.23.3和1.23.4和1.23.5和1.23.6和1.24.0 文档以及安装包已生成。后续尽可能第一时......
  • 在Kubernetes上安装Netdata的方法
    介绍Netdata可用于监视kubernetes集群并显示有关集群的信息,包括节点内存使用率、CPU、网络等,简单的说,Netdata仪表板可让您全面了解Kubernetes集群,包括在每个节点上运行的......
  • 在k8s(kubernetes)上安装 ingress V1.1.3
    介绍Ingress公开了从集群外部到集群内服务的HTTP和HTTPS路由。流量路由由Ingress资源上定义的规则控制。下面是一个将所有流量都发送到同一Service的简单Ingres......
  • kubernetes(k8s) 安装 Prometheus + Grafana
    kubernetes(k8s)安装Prometheus+Grafana组件说明MetricServer:是kubernetes集群资源使用情况的聚合器,收集数据给kubernetes集群内使用,如kubectl,hpa,scheduler等。Pro......
  • docker方式实现postgres数据持久化离线安装
    保存镜像root@hello:~#dockerpullpostgresUsingdefaulttag:latestlatest:Pullingfromlibrary/postgresa2abf6c4d29d:Alreadyexistse1769f49f910:Pullcomple......
  • kubernetes(k8s)部署 Metrics Server 资源
        资源使用指标,例如容器CPU和内存使用率,可通过MetricsAPI在Kubernetes中获得。这些指标可以直接被用户访问,比如使用kubectltop命令行,或者被集群中的控制器......
  • 06. Kubernetes - 集群安装(二进制)
    安装准备前面安装kubeadm的时候CoreDNS和ETCD都是托管在集群内部的。而但是对于二进制安装,它们都会以守护进程的方式直接运行在宿主机,这也是在生产环境比较推荐的......
  • 二进制安装Kubernetes(k8s) v1.25.0 IPv4/IPv6双栈
    二进制安装Kubernetes(k8s)v1.25.0IPv4/IPv6双栈Kubernetes开源不易,帮忙点个star,谢谢了......
  • nginx python webpy 配置安装
    安装webpy$wgethttp://webpy.org/static/web.py-0.34.tar.gz$tarxvzfweb.py-0.34.tar.gz$cdweb.py-0.34$sudopythonsetup.pyinsta......
  • Linux下的lua和boost c++的搭建和安装
    先下载lua,boostc++​​http://www.lua.org/versions.html#5.2​​​​http://www.boost.org/​​ ​​http://sourceforge.net/projects/luabind/​​1.安装lua[root@l......