安装以下

wget https://raw.githubusercontent.com/g114486803g/k8s-/master/%E9%9B%86%E7%BE%A4%E8%B5%84%E6%BA%90%E5%AF%B9%E8%B1%A1%E7%9B%91%E6%8E%A7/kube-state-metrics-deploy.yaml

wget https://raw.githubusercontent.com/g114486803g/k8s-/master/%E9%9B%86%E7%BE%A4%E8%B5%84%E6%BA%90%E5%AF%B9%E8%B1%A1%E7%9B%91%E6%8E%A7/kube-state-metrics-rbac.yaml

wget https://raw.githubusercontent.com/g114486803g/k8s-/master/%E9%9B%86%E7%BE%A4%E8%B5%84%E6%BA%90%E5%AF%B9%E8%B1%A1%E7%9B%91%E6%8E%A7/kube-state-metrics-svc.yaml

网速太卡可以选择以下方式

git clone https://gitee.com/jbjb123/draft.git
cd draft/kube-state-metrics/
 kubectl apply -f .
deployment.apps/kube-state-metrics unchanged
serviceaccount/kube-state-metrics unchanged
clusterrole.rbac.authorization.k8s.io/kube-state-metrics unchanged
clusterrolebinding.rbac.authorization.k8s.io/kube-state-metrics unchanged
service/kube-state-metrics unchanged
[root@build32-8 monit]# kubectl get pods -n kube-system | grep kube-state
kube-state-metrics-5d5bc95c7b-wdvjc   1/1     Running   0          14m
[root@build32-8 monit]# kubectl get svc -n kube-system | grep kube-state
kube-state-metrics    NodePort    172.16.255.222   <none>        8080:30272/TCP   14m

然后访问得到以下
在这里插入图片描述

prometheus服务端配置

  - job_name: 'k8s-yun'
    metrics_path: "/metrics"
    scrape_interval: 5s
    static_configs:
    - targets: ['10.22.8.17:30272']
      labels:
        instance: 'k8s-yun'

重启生效

docker exec -it prometheus promtool check config /etc/prometheus/prometheus.yml
docker exec -it prometheus kill -HUP  1
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐