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

ArgoCD无法识别ApplicationSets,部署后无预期应用显示求助

问题描述

我正尝试配置Argo Application Sets,但无法让设置正常运行。

目录结构

.
├── kubernetes-deployments
│   └── core
│       ├── argo-cd
│       │   ├── Chart.yaml
│       │   └── values.yaml
│       └── cilium
│           ├── Chart.yaml
│           └── values.yaml
└── README.md

使用的values文件

argo-cd:
  enabled: true
  dex:
    enabled: false
  notifications:
    enabled: false
  applicationSet:
    enabled: true
  server:
    extraArgs:
      - --insecure
  namespaceOverride: "argo-cd"
  server:
    service:
      type: NodePort
      nodePort: 32080
applicationsets:
  core:
    goTemplate: true
    generators:
      - git:
          repoURL: https://mygitrepo.git
          revision: HEAD
          directories:
            - path: kubernetes-deployments/core/*
    template:
      metadata:
        name: '{{path.basename}}'
        labels: {}
      spec:
        project: default
        source:
          repoURL: https://mygitrepo.git
          targetRevision: HEAD
          path: "{{ .path.path }}"
          helm: &appsets-helm
            valueFiles:
              - values.yaml
        destination: &appsets-destination
          server: https://kubernetes.default.svc
          namespace: "{{ base .path.path }}"
        revisionHistoryLimit: 5
        syncPolicy:
          syncOptions: &appsets-sync-options
            - ApplyOutOfSyncOnly=true
            - CreateNamespace=true
            - RespectIgnoreDifferences=true
            - PruneLast=true
        ignoreDifferences: []
    syncPolicy:
      preserveResourcesOnDeletion: true
      applicationsSync: sync

使用的Chart文件

apiVersion: v2
description: A Helm chart for Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes.
name: argo-cd
version: 7.8.2
home: https://github.com/argoproj/argo-helm
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
sources:
  - https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd
  - https://github.com/argoproj/argo-cd
dependencies:
  - name: argo-cd
    version: 7.8.2
    repository: https://argoproj.github.io/argo-helm
    condition: argo-cd.enabled

  - name: argocd-apps
    version: 2.0.0
    repository: https://argoproj.github.io/argo-helm
    condition: argocd-apps.enabled

已完成ArgoCD部署、初始密码设置、连接GitHub仓库,但Argo UI里看不到预期的Cilium和ArgoCD应用。


排查与解决步骤

1. 修正Helm values的结构问题

你的Chart依赖了argocd-apps,但当前values里的applicationsets是直接平级写的,不符合argocd-apps的配置结构,导致Helm不会生成对应的ApplicationSet资源。

需要把applicationsets嵌套到argocd-apps节点下,同时开启argocd-apps.enabled:

argocd-apps:
  enabled: true
  applicationsets:
    core:
      goTemplate: true
      generators:
        - git:
            repoURL: https://mygitrepo.git
            revision: HEAD
            directories:
              - path: kubernetes-deployments/core/*
      template:
        metadata:
          name: '{{path.basename}}'
          labels: {}
        spec:
          project: default
          source:
            repoURL: https://mygitrepo.git
            targetRevision: HEAD
            path: "{{ .path.path }}"
            helm: &appsets-helm
              valueFiles:
                - values.yaml
          destination: &appsets-destination
            server: https://kubernetes.default.svc
            namespace: "{{ base .path.path }}"
          revisionHistoryLimit: 5
          syncPolicy:
            syncOptions: &appsets-sync-options
              - ApplyOutOfSyncOnly=true
              - CreateNamespace=true
              - RespectIgnoreDifferences=true
              - PruneLast=true
          ignoreDifferences: []
      syncPolicy:
        preserveResourcesOnDeletion: true
        applicationsSync: sync

2. 统一模板语法

你开启了goTemplate: true,但模板里混用了两种语法:

  • {{path.basename}}是ArgoCD原生模板函数
  • {{ base .path.path }}是Go模板函数

两种方案二选一:

  • 关闭goTemplate: true,把namespace的模板改成{{path.basename}}
  • 保留goTemplate: true,把name的模板改成{{ base .path.path }}

3. 验证Git生成器的路径匹配

先确认Git仓库里kubernetes-deployments/core/argo-cd、kubernetes-deployments/core/cilium目录确实存在,且HEAD指向的分支正确。

再通过命令查看ApplicationSet的状态,确认生成器是否找到目标目录:

kubectl describe applicationset core -n argo-cd

查看Events或Status部分,有没有生成应用的记录,或者路径不存在、仓库权限报错等信息。

4. 检查ArgoCD项目权限

确认default项目允许部署到argo-cd和cilium命名空间:
在Argo UI的Settings -> Projects里查看default项目的配置,确保Destination规则包含目标命名空间,或者设置为允许所有命名空间。

5. 查看ApplicationSet控制器日志

通过日志定位具体错误:

kubectl logs -n argo-cd deployment/argocd-applicationset-controller -f

日志会显示模板渲染失败、仓库访问权限不足、资源创建被拒绝等具体问题。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 13:53:14