惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
Jina AI
Jina AI
G
Google Developers Blog
Last Week in AI
Last Week in AI
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
The GitHub Blog
The GitHub Blog
D
Docker
量子位
罗磊的独立博客
腾讯CDC

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
OpenEBS 证书过期导致服务不可用
微信公众号 · 2022-09-09 · via 陈少文的网站

Please enable Javascript to view the contents

1. 安装方式

1
2
kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml
kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

OpenEBS 主要用来给 Tekton 流水线作为默认的存储使用。之前,我也试过 Longhorn,但是高峰期扛不住,流水线 Pending。而卸载 Longhorn 之后有残留,导致 kube-apiserver 一直报错,最后花了很大力气才删除。

2. Kubernetes 集群证书过期之后,OpenEBS 不可用

Kubernetes 集群和 OpenEBS 组件是同一天安装的。Kubernetes 证书过期之后,通过 kubeadm certs renew all 很快完成了更新;之前一直没太关注的 OpenEBS 证书也过期了。

  • Tekton Controller 报错
1
2
3
4
{"level":"info","ts":"2022-09-08T07:58:39.882Z",
"logger":"tekton-pipelines-controller.event-broadcaster",
"caller":"record/event.go:282",
"msg":"Event(v1.ObjectReference{Kind:\"PipelineRun\", Namespace:\"qsearch\", Name:\"p-cccq1buj5i3oh0tp2ueg\", UID:\"a1e15eee-4c44-4867-ac0e-decc16a1a0c8\", APIVersion:\"tekton.dev/v1beta1\", ResourceVersion:\"230683178\", FieldPath:\"\"}): type: 'Warning' reason: 'InternalError' 1 error occurred:\n\t* failed to create PVC pvc-6dc4355ffe: Internal error occurred: failed calling webhook \"admission-webhookopenebs.io\": Post \"https://admission-server-svc.openebs.svc:443/validate?timeout=5s\": x509: certificate has expired or is not yet valid: current time 2022-09-08T07:58:39Z is after 2022-09-08T07:17:40Z\n\n","commit":"7ca5d61"}
  • OpenEBS Admission Server 报错
1
2022/09/08 07:53:45 http: TLS handshake error from x.x.x.x:5838: remote error: tls: bad certificate

3. 解决办法

  • 备份 openebs-validation-webhook-cfg
1
kubectl get ValidatingWebhookConfiguration openebs-validation-webhook-cfg -o yaml > openebs-validation-webhook-cfg.yaml
  • 删除 openebs-validation-webhook-cfg
1
kubectl delete ValidatingWebhookConfiguration openebs-validation-webhook-cfg

这是社区 Issues 给出的一个方案,参考链接: https://github.com/openebs/openebs/issues/3329

看起来 OpenEBS 社区还没有复现出这个问题,也没来得及修复。最近我刚升级 OpenEBS 到 openebs/admission-server:2.12.1 版本。

4. Why

  • 当我们删除 openebs-validation-webhook-cfg 时,删除的是什么

查看删除的对象:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
cat openebs-validation-webhook-cfg.yaml

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: openebs-validation-webhook-cfg
webhooks:
- admissionReviewVersions:
  - v1
  clientConfig:
    caBundle: xxx

将证书进行 Base64 解码:

1
echo xxx | base64 -d > openebs.crt

查看证书详情:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
openssl x509 -noout -text -in openebs.crt

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 0 (0x0)
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN = admission-server-svc-ca
        Validity
            Not Before: Sep  8 07:17:40 2021 GMT
            Not After : Sep  6 07:17:40 2031 GMT
        Subject: CN = admission-server-svc-ca

实际上 openebs-validation-webhook-cfg 中的证书并未过期,删除 openebs-validation-webhook-cfg 意味着在调用 OpenEBS 服务时,不进行准入控制,不校验数据的合法性。kube-apiserver 不会调用 admission-server-svc.openebs.svc,也就不会报错。

  • 到底是什么证书过期

在 admission-server-secret 中,我找到了两个证书,一个是 app.crt,一个是 ca.crt。

1
2
3
4
5
6
7
kubectl -n openebs get secret admission-server-secret   -o yaml

apiVersion: v1
data:
  app.crt: xxxx
  app.pem: xxxx
  ca.crt: xxx

ca.crt 证书和上面的一样,是一个十年期的证书。而 app.crt 是一个一年期的证书。查看证书详情:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
openssl x509 -noout -text -in app.crt

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 389184800153601983 (0x566a983852307bf)
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN = admission-server-svc-ca
        Validity
            Not Before: Sep  8 07:17:40 2021 GMT
            Not After : Sep  8 07:17:40 2022 GMT
  • 怎么更新证书

在最新安装的 OpenEBS 版本中,已经找不到 admission-server-secret 这个对象,也没有 openebs-validation-webhook-cfg。同时,在升级 OpenEBS 的集群上也没有找到引用证书的地方,甚是奇怪。

1
2
3
4
kubectl -n openebs get all,sa,secret -o yaml|grep admission-server-secret

    name: admission-server-secret
    selfLink: /api/v1/namespaces/openebs/secrets/admission-server-secret

我的怀疑是,一年前安装的 OpenEBS 是有 admission-server-secret 用于 ValidatingWebhookConfiguration 的。最近一次 OpenEBS 升级残留了之前版本的配置,导致了这次奇怪的现象。

由于没有地方引用这个证书,也就不需要更新,直接备份之后删掉就行。


微信公众号