KubeSphere 镜像构建器(S2I)服务证书过期解决方案

目前 KubeSphere 所有 3.x.x 版本,如果开启了 DevOps 模块并使用了镜像构建器功能(S2I)都会遇到证书过期问题。

解决方法

已开启 DevOps 模块

下载这个更新 S2I 服务证书压缩包,上传到任一可以访问 K8s 集群的节点;

  1. 把上传的压缩包解压
  2. 进入解压后的目录
  3. 执行更新证书的脚本 ./update-s2i-cert.sh
# 上传压缩包到可访问 k8s 集群的节点
...
# 解压缩
$ tar -zxvf update-s2i-cert.tar.gz
update-s2i-cert/
update-s2i-cert/config/
update-s2i-cert/config/certs/
update-s2i-cert/config/certs/server.crt
update-s2i-cert/config/certs/ca.crt
update-s2i-cert/config/certs/server.key
update-s2i-cert/update-s2i-cert.sh
 
# 执行更新证书脚本
$ cd update-s2i-cert
$ ./update-s2i-cert.sh
Update Secret: s2i-webhook-server-cert..
secret/s2i-webhook-server-cert patched
Update ValidatingWebhookConfiguration validating-webhook-configuration..
validatingwebhookconfiguration.admissionregistration.k8s.io/validating-webhook-configuration patched
Update MutatingWebhookConfiguration mutating-webhook-configuration..
mutatingwebhookconfiguration.admissionregistration.k8s.io/mutating-webhook-configuration patched
Restart s2ioperator server..
statefulset.apps/s2ioperator restarted
Done.
...

执行完上面3步后,等待 pod s2ioperator-0 重启成功就可以了。

未开启 DevOps 模块

在已经创建的 KubeSphere 环境里,还未开启 DevOps 模块,如果需要开启 DevOps 模块,也会遇到由于 S2I 证书过期导致开启 DevOps 模块失败的情况。

下面针对 KubeSphere 3.3.0、3.3.1、3.3.2、3.4.0、3.4.1 这几个版本,可以使用下面的方式来解决此问题:

  1. 获取 ks-installer 镜像
  2. 更新 ks-installer 镜像
# 执行下面命令,获取 ks-installer 镜像
$ kubectl -n kubesphere-system get deployments ks-installer --no-headers -o custom-columns=:.spec.template.spec.containers[0].image
kubesphere/ks-installer:v3.3.0
 
# 基于获取的镜像,在镜像最后加上 ‘-patch.0’ ,执行下面命令更新 ks-installer 镜像
$ kubectl -n kubesphere-system patch deployments ks-installer --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "kubesphere/ks-installer:v3.3.0-patch.0"}]'

更新镜像后 ks-installer 会自动重启并根据 ClusterConfiguration 里的配置安装各个开启的未安装的模块。

如果上述方案未能解决您的问题,请移步论坛交流:https://ask.kubesphere.io/forum/。

本文由博客一文多发平台 OpenWrite 发布!