部署localpv 时提示已经存在,问题复现:最开始我直接把 blueking 命名空间删除了,然后又把 sc 删除了,再次部署就出现这种问题了
[root@master01 blueking]# helmfile -f 00-localpv.yaml.gotmpl sync
ARGS:
0: helm (4 bytes)
1: upgrade (7 bytes)
2: --install (9 bytes)
3: --reset-values (14 bytes)
4: localpv (7 bytes)
5: charts/provisioner-2.4.0.tgz (28 bytes)
6: --version (9 bytes)
7: 2.4.0 (5 bytes)
8: --wait (6 bytes)
9: --wait-for-jobs (15 bytes)
10: --timeout (9 bytes)
11: 600s (4 bytes)
12: --create-namespace (18 bytes)
13: --namespace (11 bytes)
14: kube-system (11 bytes)
15: --values (8 bytes)
16: /tmp/helmfile044238900/kube-system-localpv-values-7cd9d9bb46 (60 bytes)
17: --history-max (13 bytes)
18: 10 (2 bytes)
ERROR:
exit status 1
EXIT STATUS
1
STDERR:
Error: rendered manifests contain a resource that already exists. Unable to continue with install: ClusterRole "localpv-provisioner-node-clusterrole" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-namespace" must equal "kube-system": current value is "blueking"
COMBINED OUTPUT:
Release "localpv" does not exist. Installing it now.
Error: rendered manifests contain a resource that already exists. Unable to continue with install: ClusterRole "localpv-provisioner-node-clusterrole" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-namespace" must equal "kube-system": current value is "blueking"
但是执行helm list -A 又没看到
[root@master01 blueking]# helm list -A
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
get sc 也没有看到
[root@master01 ~]# kubectl get sc
No resources found
最后再网上找到这个命令解决了
helm template <NAME> <CHART> --namespace <NAMESPACE> | kubectl delete -f -
获取 NAME
获取 CHART
最终执行
[root@master01 blueking]# helm template localpv stable/cluster-overprovisioner --namespace blueking | kubectl delete -f -
WARNING: This chart is deprecated
Warning: scheduling.k8s.io/v1beta1 PriorityClass is deprecated in v1.14+, unavailable in v1.22+; use scheduling.k8s.io/v1 PriorityClass
Error from server (NotFound): error when deleting "STDIN": priorityclasses.scheduling.k8s.io "default" not found
Error from server (NotFound): error when deleting "STDIN": priorityclasses.scheduling.k8s.io "overprovisioning" not found
上面虽然有报错,可以不用管
再次执行安装,成功了
[root@master01 blueking]# helmfile -f 00-localpv.yaml.gotmpl sync
Affected releases are:
localpv (./charts/provisioner-2.4.0.tgz) UPDATED
Upgrading release=localpv, chart=charts/provisioner-2.4.0.tgz
Release "localpv" does not exist. Installing it now.
NAME: localpv
LAST DEPLOYED: Sat Oct 15 23:11:48 2022
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
provisioner installed
Listing releases matching ^localpv$
localpv kube-system 1 2022-10-15 23:11:48.757144765 +0800 CST deployed provisioner-2.4.0 2.4.0
UPDATED RELEASES:
NAME CHART VERSION
localpv ./charts/provisioner-2.4.0.tgz
[root@master01 blueking]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-storage (default) kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 12m