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 证书也过期了。
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 升级残留了之前版本的配置,导致了这次奇怪的现象。由于没有地方引用这个证书,也就不需要更新,直接备份之后删掉就行。