5

Dapr 证书过期了怎么办? 别慌,有救! - 张善友

 2 years ago
source link: https://www.cnblogs.com/shanyou/p/16708058.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Dapr 证书过期了怎么办? 别慌,有救!

Dapr 默认证书有效时间是1年,证书过期后就不能执行相关控制面和数据面的交互了,如下图:

image

二、查看证书有效时间

通过dapr mtls expiry 看到期时间,具体参见命令https://v1-7.docs.dapr.io/reference/cli/dapr-mtls/dapr-mtls-expiry/

image

三、解决方案

Dapr 支持使用 Dapr 控制平面、Sentry 服务(中央证书颁发机构 (CA))对 Dapr 实例之间的通信进行传输中加密。

Dapr 允许运维和开发人员引入他们自己的证书,或者让 Dapr 自动创建和保存自签名的根证书和颁发者证书。具体参见

https://docs.dapr.io/operations/security/mtls/

Dapr 在1.7版本引入了一个新的命令:

dapr mtls renew-certificate -k --valid-until <days> –restart

生成全新的根证书和颁发者证书,由新生成的私钥签名。Dapr sentry service必须重新启动随后的其余控制平面服务才能读取新证书。这可以通过向--restart命令提供标志来完成。

对于 1.7 以下版本, 只能手工进行操作,具体可以参考 文档 https://v1-5.docs.dapr.io/operations/security/mtls/#bringing-your-own-certificates ,更新完Dapr 证书,则必须重新启动 Dapr Sentry 服务,然后是 Dapr 控制平面服务的其余部分。

kubectl rollout restart deploy/dapr-sentry -n <DAPR_NAMESPACE>

一旦sentry 完全重新启动运行:

kubectl rollout restart deploy/dapr-operator -n <DAPR_NAMESPACE>
kubectl rollout restart statefulsets/dapr-placement-server -n <DAPR_NAMESPACE>

接下来,您必须重新启动所有启用 Dapr 的 pod。推荐的方法是重新启动部署:

kubectl rollout restart deploy/<myapp> –n <APP_NAMESPACE>

在成功重新启动所有部署(并因此加载新的 Dapr 证书)之前,由于证书不匹配,您将经历潜在的停机时间。

1.7 版本以后Dapr 在这个方面做的更完善了,为 Dapr 控制平面 mTLS 证书过期设置监控
从 mTLS 根证书到期前 30 天开始,Dapr 哨兵服务将发出每小时警告级别的日志,指示根证书即将到期。 作为在生产中运行 Dapr 的最佳操作实践,我们建议为这些特定哨兵服务日志配置监控,以便您了解即将到期的证书。

image

从 1.7.0 版开始,作为提醒您即将到来的证书到期的附加工具,CLI 现在会在您与基于 Kubernetes 的部署交互时打印证书到期状态。

image

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK