KubeSphere版本信息
v3.x.x

问题

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

这个是由于之前 DevOps S2I 内置的证书过期时间是 2024.02.14 ,现在只需要更新证书就可以了;

解决步骤

update-s2i-cert.tar.gz

(备用下载地址:update-s2i-cert.tar.gz

点击上面链接,下载更新 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. 清理开启失败的残留 release

  2. 获取 ks-installer 镜像

  3. 在镜像后加上 -patch.0 并更新 ks-installer 镜像

# 清理开启失败的残留 release
helm -n kubesphere-devops-system delete devops

# 执行下面命令,获取 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 里的配置安装各个开启的未安装的模块;

    HanJ 确实,这两个版本的镜像构建有点问题,已经在重新创建了。

      yudong 我执行脚本更换书之后,虽然没有报证书的错误的,但是出现另一个报错,我是3.3.2版本的,好像是uid不匹配的问题,是你们出现的问题吗

        HanJ 这个可能还是证书的问题,稍等我们正在更新 3.3.2 的 patch 镜像,然后替换下镜像试试 ;

        HanJ 3.3.2 的 patch 镜像也已经有了,可以更新了。

          yudong

          更新了镜像,还是有证书问题。执行下楼主的update_s2i-cert.sh 就好了。多谢楼主。

            HanJ 麻烦执行下面的操作,更进一步确认错误原因:

            1. 执行下命令进入ks-installe容器内(替换下命令中 pod):

              kubectl -n kubesphere-system exec -it ks-installer-7c549cbd47-d42md -- bash

            2. 进入目录 /kubesphere/results/devops/devops/job_events ,执行命令查找devops安装的日志文件:

              grep Convert\ ks-devops\ to\ helm\ mananged *.json |grep -l -E 'Error|ERROR'

            3. 在上面查找出来的文件中查找更详细的错误信息;

            根据错误信息,分析下原因,或者上传到错误信息;

            • HanJ 回复了此帖

              yudong No, 之前因为证书问题enable devops failed,然后我uninstall 了 deveops ,重装了一次。同样出现证书问题后,又执行了一遍update-s2i-cert.sh 更新了证书。于是好了。

              yudong 首先是没有这个路径 /kubesphere/results/ks-devops/ks-devops/job_events

              只有/kubesphere/results/devops/devops/job_events

              其次执行你的命令后没有结果

                HanJ 是的 上面命令不完成;

                我又测试验证了下,你的环境现在的问题可能是由于有之前开启 DevOps 残留的 release,可以先清理再重启 ks-installer 下:

                # 清理残留 release
                helm -n kubesphere-devops-system delete devops
                
                # 重启 ks-installer ,重新安装 devops
                kubectl -n kubesphere-system rollout restart deployment ks-installer
                6 天 后
                8 天 后
                12 天 后