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重启,重启就会重新加载配置文件。

相关推荐
Apple_羊先森33 分钟前
ORACLE数据库巡检SQL脚本--22、检查碎片程度最高的业务表
数据库·sql·oracle
OnYoung2 小时前
更优雅的测试:Pytest框架入门
jvm·数据库·python
山岚的运维笔记2 小时前
SQL Server笔记 -- 第85章:查询提示
数据库·笔记·sql·microsoft·sqlserver
chilavert3182 小时前
技术演进中的开发沉思-371:final 关键字(中)
java·前端·数据库
tryCbest3 小时前
SQL Server数据库
数据库·sql server
_codemonster4 小时前
PreparedStatement 和 Statement的区别
数据库·oracle
恒云客4 小时前
python uv debug launch.json
数据库·python·json
愈努力俞幸运4 小时前
第5章数据库,实体关系图,ER图
数据库·oracle