我正在寻找一种使用 helm v3 来从给定版本中删除某些修订的方法。
假设我得到了
my-release
,其修订版为 1,2,2,4,在运行 helm upgrade
时自动创建并部署新修订版。如果我遇到版本 4 的问题,我可以使用 helm rollback my-release 3
。
有没有办法删除特定修订版 - 比如说 1 和 2
不幸的是,helm uninstall my-release 1 不起作用。
我只是有一个用例,在我看来,删除修订版本是有意义的:
有4次修改:
$ helm history rocketchat-b '--namespace' 'rocketchat-b'
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
40 Fri Nov 3 12:16:38 2023 superseded rocketchat-1.0.0 Rollback to 38
43 Tue Nov 7 15:19:02 2023 superseded rocketchat-6.4.5-1 6.4.5 Upgrade "rocketchat-b" failed: failed to create resource: Ingress.extensions "rocketchat-b-rocketchat" is invalid: spec.rules[0].http.paths[0].path: Invalid value: "": must be an absolute path
44 Tue Nov 7 15:19:05 2023 failed rocketchat-6.4.5-1 6.4.5 Rollback "rocketchat-b" failed: failed to create resource: Ingress.extensions "rocketchat-b-rocketchat" is invalid: spec.rules[0].http.paths[0].path: Invalid value: "": must be an absolute path
45 Tue Nov 7 15:47:31 2023 deployed rocketchat-6.4.5-1 6.4.5 Upgrade complete
还有一个版本 39,该版本实际上是最后一个有效的版本,但它已经被自动删除(这是用户可能想要避免的)。 40 是错误版本的部署,它部分工作,43 和 44 完全是垃圾,因为 pod 和服务的端口号不匹配。我现在想保留 40,即使我进行了更多升级(更喜欢 39,但那个已经消失了)。 我假设,helm 总是保留 4 个修订版本。也许不是最新的,但如果我删除 41 和 42,40 留在我的系统中的可能性会更大。
我通过删除它们的秘密来删除这些版本:
$ kubectl -n rocketchat-b get secret
NAME TYPE DATA AGE
sh.helm.release.v1.rocketchat-b.v40 helm.sh/release.v1 1 4d22h
sh.helm.release.v1.rocketchat-b.v43 helm.sh/release.v1 1 19h
sh.helm.release.v1.rocketchat-b.v44 helm.sh/release.v1 1 19h
sh.helm.release.v1.rocketchat-b.v45 helm.sh/release.v1 1 18h
$ kubectl -n rocketchat-b delete secret sh.helm.release.v1.rocketchat-b.v43
secret "sh.helm.release.v1.rocketchat-b.v43" deleted
$ kubectl -n rocketchat-b delete secret sh.helm.release.v1.rocketchat-b.v44
secret "sh.helm.release.v1.rocketchat-b.v44" deleted
$ kubectl -n rocketchat-b get secret
NAME TYPE DATA AGE
sh.helm.release.v1.rocketchat-b.v40 helm.sh/release.v1 1 4d22h
sh.helm.release.v1.rocketchat-b.v45 helm.sh/release.v1 1 18h
剩下的正是我想要的:
$ helm history rocketchat-b '--namespace' 'rocketchat-b'
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
40 Fri Nov 3 12:16:38 2023 superseded rocketchat-1.0.0 Rollback to 38
45 Tue Nov 7 15:47:31 2023 deployed rocketchat-6.4.5-1 6.4.5 Upgrade complete