首页 > 解决方案 > Helmfile 如何将现有资源更改为另一个图表

问题描述

我想将sw-api图表模板中的官方网站这个图表移动到独立图表,并将文件移出sw-api的模板然后使用helmfile apply,给我这个错误。

这是我的错误代码

Error: Failed to render chart: exit status 1: 
Error: rendered manifests contain a resource that already exists. 
Unable to continue with install: ConfigMap "official-web-config" in namespace "develop" exists and cannot be imported into the current release: invalid ownership metadata; 
annotation validation error: key "meta.helm.sh/release-name" must equal "official-web": current value is "sw-api"

标签: kubernetesgoogle-kubernetes-enginekubernetes-helm

解决方案


现在这是我的 helm 文件夹

── sw-api
│   ├── Chart.yaml
│   ├── templates
│   │   ├── micros-worker
│   │   │   ├── configMap.yaml
│   │   │   ├── deployment.yaml
│   │   │   └── hpa.yaml
│   │   └── official-web
│   │       ├── certificate.yaml
│   │       ├── configMap.yaml
│   │       ├── deployment.yaml
│   │       ├── hpa.yaml
│   │       ├── ingress.yaml
│   │       ├── ip.yaml
│   │       └── svc.yaml
│   ├── values-dev.yaml
├── sw-api-values.yaml.gotmpl
── swagger
│   ├── Chart.yaml
│   ├── templates
│   │   ├── _helpers.tpl
│   │   ├── deployment.yaml
│   │   └── svc.yaml
│   ├── values-dev.yaml

我变成这样

── official-web
│   ├── Chart.yaml
│   ├── templates
│   │   ├── _helpers.tpl
│   │   ├── certificate.yaml
│   │   ├── configMap.yaml
│   │   ├── deployment.yaml
│   │   ├── hpa.yaml
│   │   ├── ingress.yaml
│   │   ├── ip.yaml
│   │   └── svc.yaml
│   ├── values-dev.yaml
├── official-web-values.yaml.gotmpl
├── sw-api
│   ├── Chart.yaml
│   │   └── micros-worker
│   │       ├── configMap.yaml
│   │       ├── deployment.yaml
│   │       └── hpa.yaml
│   ├── values-dev.yaml
│   └── values-test.yaml
├── sw-api-values.yaml.gotmpl

并执行 helmfile apply 命令(在命名空间“develop”中):

helmfile -f helmfile.yaml --log-level=debug --debug -e dev apply

此错误显示在 hemlfile 应用之前

Error: Failed to render chart: exit status 1: 
Error: rendered manifests contain a resource that already exists. 
Unable to continue with install: ConfigMap "official-web-config" in namespace "develop" exists and cannot be imported into the current release: invalid ownership metadata; 
annotation validation error: key "meta.helm.sh/release-name" must equal "official-web": current value is "sw-api"

推荐阅读