k8s-监控数据grafana展示
//
# 登录Grafana
默认账号密码:admin/admin,
grafana.yfklife.cn
grafana官方查找合适的dashboard (opens new window)
- 交互登录grafana POD 安装插件
kubectl exec -it -n devops $(kubectl get pod -n devops |grep grafana |awk '{print $1}') bash #登录grafana容 器
# 安装grafana插件
grafana-cli plugins install grafana-kubernetes-app
grafana-cli plugins install grafana-clock-panel
grafana-cli plugins install grafana-piechart-panel
grafana-cli plugins install briangann-gauge-panel
grafana-cli plugins install natel-discrete-panel
exit # 退出容器
kubectl delete pod -n devops $(kubectl get pod -n devops |grep grafana |awk '{print $1}') # 删除pod,重新启动一个
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 配置prometheus.yml
prometheus官方地址 (opens new window)
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_timeout: 10s
alerting:
alertmanagers:
- static_configs:
- targets: ["alertmanager"]
rule_files:
- "/data/etc/rules.yml"
scrape_configs:
- job_name: 'etcd'
tls_config:
ca_file: /data/etc/ca.pem
cert_file: /data/etc/client.pem
key_file: /data/etc/client-key.pem
scheme: https
static_configs: # 静态配置
- targets:
- '192.168.14.12:2379'
- '192.168.14.21:2379'
- '192.168.14.22:2379'
#------部分省略
- job_name: 'node'
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __address__
replacement: ${1}:9100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- 参考配置
http://xxxxxxxxx/plugins/grafana-kubernetes-app/page/cluster-config
,改成你的grafana地址
# 刷新Prometheus配置
curl -X POST http://prometheus.yfklife.cn/-/reload
# 配置grafana数据源(prometheus)
- 启用【kubernetes】插件,点击左边【k8s图标】,点击 【New Clusters】
复制证书 client证书为/root/.kube/config,需要对其进行解码,我这里是二进制安装的,目录文件有点不一样
ca.pem ,client.pem ,client-key.pem
cat /opt/kubernetes/server/bin/conf/kubelet.kubeconfig | grep certificate-authority-data | cut -d ' ' -f 6 | base64 -d
cat /opt/kubernetes/server/bin/conf/kubelet.kubeconfig | grep client-certificate-data | cut -d ' ' -f 6 | base64 -d
cat /opt/kubernetes/server/bin/conf/kubelet.kubeconfig | grep client-key-data | cut -d ' ' -f 6 | base64 -d
1
2
3
4
2
3
4
- prometheus 数据源(tls 首字母)
- k8s 数据源
- 导入kubernetes的dashboard
- kubernetes 集群列表
- 单个kubernetes集群信息
# 总图
# 个人存储下载地址。。。
Etcd Dashboard.json
Generic Dashboard.json
JMX Dashboard.json
K8s Cluster-1654615558074.json
K8s Container-1654615571071.json
K8s Deployments-1654615540645.json
K8s Node-1654615581771.json
Traefik Dashboard.json
prometheus.yml
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
如果对你有帮助,给博主买杯咖啡吧🤞🤞
//
如果此文章对您有帮助,点击 -->> 请博主喝咖啡 (opens new window)
上次更新: 2023/11/20, 16:23:11