ArgoCD中Helm多源配置问题:未打包Chart报错如何解决?
ArgoCD多源Helm配置问题解答
问题场景
配置了ArgoCD多源部署,计划从一个仓库拉取values配置,另一个仓库拉取未打包的Helm模板,对应的Application配置如下:
apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: test-app namespace: argocd spec: sources: - repoURL: 'https://github.com/org/values-repo.git' targetRevision: branch1 ref: valuesRepo helm: releaseName: sample-release - repoURL: 'https://github.com/org/helm-chart.git' chart: branch1 targetRevision: 0.1.0 helm: releaseName: sample-release valueFiles: - $valuesRepo/helm-values/development/sample-values.yaml destination: name: 'dev-cluster' namespace: 'test-ns' project: test-project
执行时出现错误:
Failed to load target state: failed to generate manifest for source 2 of 2: rpc error: code = Unknown desc = helm pull --destination /tmp/a59cfffe-fe29-4196-90b3-965445e41d68 --version 0.1.1 --username ****** --password ****** --repo https://github.com/org/helm-chart.git charts/test-chart failed exit status 1: Error: looks like "https://github.com/org/helm-chart.git" is not a valid chart repository or cannot be reached: failed to fetch https://github.com/org/helm-chart.git/index.yaml : 404 Not Found
疑问:ArgoCD的多源配置是否要求Helm Chart必须是已打包的?当前Chart尚未打包。
解答
ArgoCD多源配置不强制要求Helm Chart必须已打包,你的问题出在配置写法错误,误将普通Git仓库当作Helm仓库处理。
错误原因
错误日志显示Helm尝试从https://github.com/org/helm-chart.git拉取Helm仓库专属的index.yaml文件,但这是存储未打包Chart的普通Git仓库,并不存在该文件,因此返回404错误。你当前配置中使用的chart字段,是用于指向Helm仓库中的Chart名称,而非Git仓库里的Chart目录。
修正后的配置
将存储未打包Chart的源按Git仓库处理,用path字段指定Chart在仓库内的目录路径,同时调整targetRevision为Git仓库的分支、commit或tag,而非Helm版本号:
apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: test-app namespace: argocd spec: sources: - repoURL: 'https://github.com/org/values-repo.git' targetRevision: branch1 ref: valuesRepo - repoURL: 'https://github.com/org/helm-chart.git' targetRevision: branch1 path: ./charts/test-chart # 替换为仓库中Helm Chart所在的实际目录 helm: releaseName: sample-release valueFiles: - $valuesRepo/helm-values/development/sample-values.yaml destination: name: 'dev-cluster' namespace: 'test-ns' project: test-project
关键配置说明
- 仅当使用Helm仓库(已打包Chart、包含
index.yaml)时,才需要使用chart字段;对于Git仓库中的未打包Chart,使用path字段指向Chart目录。 - 第一个源仅提供values文件,无需配置
helm相关内容。 targetRevision对于Git源需指定Git仓库的分支、commit哈希或tag,而非Helm Chart的版本号。
内容的提问来源于stack exchange,提问作者raghu_manne
相关产品推荐
相关产品推荐

