kubernetes性能监控平台

1 集群资源监控概述

1)监控指标

集群监控:①节点资源利用率;②节点数;③运行Pods;
Pod监控:①容器指标;②应用程序指标;

2)监控平台搭建方案 Prometheus + Grafana

Prometheus:①开源;②监控,报警,数据库;③以http协议周期性抓取被监控组件状态;④集成简单,使用http接入即可;
Grafana :①开源的数据分析和可视化工具;②支持多种数据源;

2 监控平台搭建

2.1 平台搭建准备

安装资源链接: kubernetes性能监控平台prometheus和grafana

mkdir /opt/module/pgmonitor
将资源解压到/opt/module/pgmonitor
查看解压后的目录文件结构

tree /opt/module/pgmonitor
=============================
/opt/module/pgmonitor
├── grafana
│   ├── grafana-deploy.yaml
│   ├── grafana-ing.yaml
│   └── grafana-svc.yaml
├── node-exporter.yaml
└── prometheus
    ├── configmap.yaml
    ├── prometheus.deploy.yml
    ├── prometheus.svc.yml
    └── rbac-setup.yaml

2 directories, 8 files

2.2 部署守护进程

kubectl delete -f node-exporter.yaml 
==============================
daemonset.apps "node-exporter" deleted
service "node-exporter" deleted
kubectl create -f node-exporter.yaml 
==============================
daemonset.apps/node-exporter created
service/node-exporter created

2.3 部署prometheus

kubectl create -f rbac-setup.yaml 
==============================
clusterrole.rbac.authorization.k8s.io/prometheus created
serviceaccount/prometheus created
clusterrolebinding.rbac.authorization.k8s.io/prometheus created
kubectl create -f configmap.yaml 
==============================
configmap/prometheus-config created
kubectl create -f prometheus.deploy.yml 
==============================
deployment.apps/prometheus created
kubectl create -f prometheus.svc.yml 
==============================
service/prometheus created

2.4 部署grafana

kubectl create -f grafana-deploy.yaml 
==============================
deployment.apps/grafana-core created
kubectl create -f grafana-svc.yaml 
==============================
service/grafana created
kubectl create -f grafana-ing.yaml 
==============================
ingress.extensions/grafana created

2.5 查看部署详情

kubectl get pods -n kube-system
==============================
NAME                                 READY   STATUS    RESTARTS   AGE
coredns-7ff77c879f-gzg2l             1/1     Running   1          21h
coredns-7ff77c879f-tg9lr             1/1     Running   1          21h
etcd-k8s-master                      1/1     Running   1          21h
grafana-core-768b6bf79c-tx85v        1/1     Running   0          2m47s
kube-apiserver-k8s-master            1/1     Running   1          21h
kube-controller-manager-k8s-master   1/1     Running   1          21h
kube-flannel-ds-gh68f                1/1     Running   1          21h
kube-flannel-ds-mm7bd                1/1     Running   1          21h
kube-flannel-ds-rj254                1/1     Running   1          21h
kube-proxy-4hjwr                     1/1     Running   1          21h
kube-proxy-ddtdq                     1/1     Running   1          21h
kube-proxy-ghxxc                     1/1     Running   1          21h
kube-scheduler-k8s-master            1/1     Running   1          21h
node-exporter-hgdl7                  1/1     Running   0          14m
node-exporter-jjk77                  1/1     Running   0          14m
prometheus-7486bf7f4b-5zv4f          1/1     Running   0          10m

2.6 打开grafana配置数据源及导入显示模板

查看grafana运行情况

kubectl get svc -n kube-system
==============================
NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
grafana         NodePort    10.99.186.219    <none>        3000:31144/TCP           5m28s
kube-dns        ClusterIP   10.96.0.10       <none>        53/UDP,53/TCP,9153/TCP   21h
node-exporter   NodePort    10.108.114.146   <none>        9100:31672/TCP           17m
prometheus      NodePort    10.104.111.45    <none>        9090:30003/TCP           12m
kubectl get svc -n kube-system -o wide

浏览器访问:http://192.168.6.112:31144/login

默认账号密码:admin/admin

配置数据源

设置显示模板

时间同步问题造成本实验无法正常显示数据

—— 尚硅谷k8s教程 学习笔记

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
)">
下一篇>>