1)监控指标
集群监控:①节点资源利用率;②节点数;③运行Pods;
Pod监控:①容器指标;②应用程序指标;
2)监控平台搭建方案 Prometheus + Grafana
Prometheus:①开源;②监控,报警,数据库;③以http协议周期性抓取被监控组件状态;④集成简单,使用http接入即可;
Grafana :①开源的数据分析和可视化工具;②支持多种数据源;
安装资源链接: 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
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
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
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
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
查看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教程 学习笔记