You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用私有仓库Values文件部署公共Helm Chart的ArgoCD应用

解决ArgoCD引用私有仓库values文件的404权限问题

问题原因

直接使用raw.githubusercontent.com的URL访问私有仓库文件会返回404,因为私有仓库的原始文件链接需要身份认证,而ArgoCD默认不会为这类HTTP URL附加已配置的私有仓库认证信息——哪怕你已经把该仓库添加到ArgoCD中。

解决方案

方案1:通过ArgoCD已配置的私有仓库引用文件

既然你已经将私有仓库添加到ArgoCD中,可直接通过仓库URL或自定义名称+文件路径的格式引用values文件,无需使用raw URL:

修改Application的helm.valueFiles配置:

helm:
  releaseName: nginx-ingress
  valueFiles:
    - 'https://github.com/<org>/<repo>.git//helm-charts/nginx-ingress/values.yaml?ref=main'

如果给私有仓库设置了自定义名称(比如private-config-repo),可简化为:

helm:
  releaseName: nginx-ingress
  valueFiles:
    - 'private-config-repo//helm-charts/nginx-ingress/values.yaml?ref=main'

格式说明:[仓库标识]//[文件路径]?ref=[分支/tag],ArgoCD会自动使用已配置的认证信息访问私有仓库文件。

方案2:使用ArgoCD多源应用(推荐)

通过多源配置,将官方Helm Chart和私有配置仓库拆分为独立源,结构更清晰且易于维护:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx-ingress-app
  namespace: argocd
spec:
  project: default
  sources:
    # 源1:官方Nginx Ingress Helm Chart
    - repoURL: 'https://kubernetes.github.io/ingress-nginx'
      targetRevision: main
      chart: ingress-nginx
      helm:
        releaseName: nginx-ingress
        # 引用第二个源中的values文件
        valueFiles:
          - $values/helm-charts/nginx-ingress/values.yaml
    # 源2:私有配置仓库
    - repoURL: 'https://github.com/<org>/<repo>.git'
      targetRevision: main
      ref: values  # 定义引用别名,供第一个源调用
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: nginx-ingress
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

这种方式下,ArgoCD会自动用已配置的认证拉取私有仓库的配置文件,彻底规避raw URL的权限问题。

方案3:通过Helm参数传入私有配置(适合简单场景)

如果自定义配置较少,可将私有仓库的values内容通过helm.values字段引入(需配合多源或ConfigMap):

helm:
  releaseName: nginx-ingress
  values: |
    {{ .Files.Get "helm-charts/nginx-ingress/values.yaml" }}
  valuesFrom:
    - configMapKeyRef:
        name: private-config
        key: values.yaml

验证步骤

  1. 确认私有仓库在ArgoCD中的连接状态正常(在ArgoCD UI的Settings -> Repositories中查看)。
  2. 应用修改后的Application配置:kubectl apply -f <your-app-file>.yaml。
  3. 查看ArgoCD应用的同步日志,确认是否成功拉取私有仓库的values文件。

内容的提问来源于stack exchange,提问作者Shammir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 17:43:19