如何从 git 存储库初始化 ArgoCD 应用程序

Mel*_* H. 1 kubernetes gitops argocd

我想直接从 git 存储库创建一个 argoCD 应用程序,即 gitOps 方式。我已经为应用程序创建了一个 CRD 文件,如下所示:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-service
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
  project: default
  source:
    path: clusters/helm-chart
    repoURL: https://github.com/user/my-repo.git
    targetRevision: HEAD
    helm:
      values: |
        image:
          repository: user/my-image
          pullPolicy: Always
          tag: xxx


Run Code Online (Sandbox Code Playgroud)

我当前的工作流程是将此 CRD 应用于我的集群k apply -f application.yaml

问题:如何指示 ArgoCD 去同步/创建我定义的应用程序,而https://github.com/user/my-repo.git无需首先“手动”创建该应用程序?

lar*_*sks 5

在某些时候,您必须手动将清单应用到您的 ArgoCD 实例。

如果您使用app-of-apps模式,您可以将其限制为单个清单,在该模式中您有一个包含所有 ArgoCD 应用程序清单的存储库。

您还可以创建ApplicationSet,以根据 git 存储库的内容、在 ArgoCD 中注册的集群名称以及其他数据,从模板自动生成 ArgoCD 应用程序。