prometheus监控etcd证书报错问题

背景

prometheus重启之后显示集群中的etcd节点全部down掉了。

在集群中查看etcd状态是正常的

进一步查看etcd日志发现

json 复制代码
{"level":"warn","ts":"2023-10-27T07:52:58.389Z","caller":"embed/config_logging.go:169","msg":"rejected connection","remote-addr":"192.168.1.38:38062","server-name":"","error":"tls: failed to verify client certificate: x509: certificate has expired or is not yet valid: current time 2023-10-27T07:52:58Z is after 2023-10-23T03:26:36Z"}

分析

Prometheus连接到etcd抓取监控信息需要配置证书才可以。

集群中的etcd证书更新之后,没有同步到Prometheus的pod中去。

解决

直接使用kubectl cp报权限错误

bash 复制代码
root@dev-k8s-master03:/etc/kubernetes/pki# kubectl cp /etc/kubernetes/pki/apiserver-etcd-client.crt -c prometheus prometheus-54b464684f-ss6vv:/prometheus/dev-etcd/apiserver-etcd-client.crt
tar: can't remove old file apiserver-etcd-client.crt: Permission denied

找到Prometheus的部署文件发现挂载的是pvc存储卷,使用的集群中storageclass存储。

从nfs-client-provisioner中找到使用的nfs服务器的地址,远程到服务器中去,手动copy证书文件。crt文件和key文件都要拷贝

bash 复制代码
root@dev-k8s-master03:/etc/kubernetes/pki# scp apiserver-etcd-client.crt nfs服务器IP地址:/nfsroot/prometheus的pvc/pod中使用的目录/

问题解决。

思考

一些排错的思路是可以学习的:比如看到etcd集群中的报错,是warn级别的,一般是客户端的报错。

而在发现etcd报错之后,登陆k8s集群正常使用,证明etcd集群本身是没有问题的。

继续分析报错是客户端连接的报错。既不是同步数据使用的2380端口,更不是提供服务的2379端口。而是remote addr。

回想自己做的操作,prometheus重启,重启就会重新加载配置文件。

相关推荐
沃尔威武5 小时前
数据库 Sinks(.net8)
数据库·.net·webview
Dreamboat¿6 小时前
SQL 注入漏洞
数据库·sql
曹牧7 小时前
Oracle数据库中,将JSON字符串转换为多行数据
数据库·oracle·json
被摘下的星星7 小时前
MySQL count()函数的用法
数据库·mysql
末央&7 小时前
【天机论坛】项目环境搭建和数据库设计
java·数据库
徒 花7 小时前
数据库知识复习07
数据库·作业
素玥8 小时前
实训5 python连接mysql数据库
数据库·python·mysql
jnrjian8 小时前
text index 查看index column index定义 index 刷新频率 index视图
数据库·oracle
瀚高PG实验室8 小时前
审计策略修改
网络·数据库·瀚高数据库
言慢行善9 小时前
sqlserver模糊查询问题
java·数据库·sqlserver