当heml应用中的value配置有错误时,会引起升级失败。crd中 HelmRelease 资源状态处于”failed“状态,kubesphere当前有bug,无法处理该状态。
1、创建 obj.yaml ,文件内容如下:
{
"status": {
"state": "active"
}
}
2、查找处于失败状态的helmreleases,第一列就是name
kubectl get helmreleases |grep failed
3、查询token
kubectl get secret -n kubesphere-system ks-installer-token-g6ddr -o yaml
”ks-installer-token-g6ddr“根据实际情况替换,可通过
kubectl get secret -n kubesphere-system | grep service-account-token 查找
拿到的token要做一下base64转码,转好的码后边用到。
4、编辑执行脚本:run.sh
#!/bin/bash
obj_file=./obj.yaml
kind=helmreleases
APISERVER=https://127.0.0.1:6443
TOKEN=eyJhbGciOiJSUzI1NiIsImtpZxxxxxxxxxxxxxxxxxx(步骤3替换)
obj=rls-oqvkk8x2wkor59(步骤2替换)echo "begin to patch $obj the file "${obj_file}
curl -XPATCH -H "Accept: application/json" -H "Content-Type: application/merge-patch+json" --header "Authorization: Bearer $TOKEN" --insecure -d @${obj_file} $APISERVER/apis/application.kubesphere.io/v1alpha1/${kind}/$obj/status
5、修正错误的values(如果不修改正确values,系统会再次执行错误。但如果你的values本身没有问题,而是其他问题引起得错误,可以忽略这个步骤)
kubectl edit helmreleases rls-oqvkk8x2wkor59
”values:“字段内容是base64编码的,将正确的values 重新编码后,替换这里的内容
6、执行 sh run.sh ,执行该操作后,系统会继续执行升级操作。