以下是在CentOS上使用K8s监控工具的常见方法:
kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/bundle.yaml。prometheus.yaml配置文件,然后执行kubectl apply -f prometheus.yaml。kubectl apply -f https://raw.githubusercontent.com/coreos/kube-prometheus/master/manifests/grafana/grafana.yaml。http://prometheus.monitoring.svc.cluster.local:9090。安装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资源使用情况。
在CentOS上安装nmon,执行yum install nmon,然后运行./nmon -c -t -r file -s 10 -f localhost_$(date +%Y%m%d_%H%M).nmon,可记录系统资源使用情况到文件。