centos

centos k8s监控工具怎么用

小樊
38
2025-08-10 21:12:46
栏目: 智能运维

以下是在CentOS上使用K8s监控工具的常见方法:

使用Prometheus和Grafana

  1. 安装Prometheus Operator:执行kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/bundle.yaml
  2. 部署Prometheus:创建prometheus.yaml配置文件,然后执行kubectl apply -f prometheus.yaml
  3. 部署Grafana:执行kubectl apply -f https://raw.githubusercontent.com/coreos/kube-prometheus/master/manifests/grafana/grafana.yaml
  4. 配置Grafana数据源:在Grafana界面中添加Prometheus数据源,填入Prometheus的服务地址,如http://prometheus.monitoring.svc.cluster.local:9090
  5. 导入Grafana面板:可从官方获取或自定义面板,导入后即可查看监控数据。

使用kubectl命令行工具

安装Metrics Server,执行kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml。然后使用kubectl top nodes查看节点资源使用情况,kubectl top pods --all-namespaces查看Pod资源使用情况。

使用nmon

在CentOS上安装nmon,执行yum install nmon,然后运行./nmon -c -t -r file -s 10 -f localhost_$(date +%Y%m%d_%H%M).nmon,可记录系统资源使用情况到文件。

0
看了该问题的人还看了