promethus监控k8s--外部
promethus监控k8s有两种方式,一直是k8s搭建自己监控自己 第二种是外部搭建好了promethus,k8s搭建pod收集信息
yaml地址为 https://github.com/starsliao/Prometheus/tree/master/kubernetes 或者 https://github.com/kubernetes/kube-state-metrics/tree/main/examples/standard 一般选择2.2.1
若官方版本下不下来换成国内源 registry.cn-shenzhen.aliyuncs.com/starsl/kube-state-metrics:v2.2.1
kubectl apply -f ./
查看是否安装成功
root@k8s-master-30-61:~/# kubectl get pods -n kube-system -o wide | grep kube-state-metrics
kube-state-metrics-548546fc89-z98wk 1/1 Running 0 1m 10.244.46.113 k8s-node02-30-63
配置prometheus.yml
- job_name: "kube-state"
metrics_path: '/metrics'
static_configs:
- targets: ['10.244.46.113:8080']
minikube或者k3s临时转发port。
kubectl port-forward kube-state-metrics-548546fc89-z98wk -n kube-system 8080:8080 8081:8081 --address 192.168.252.128