Git 项目组织方法
在根目录创建 ApplicationSet
在 Git 仓库根目录下创建 argo-apps.yaml
的文件,定义 ArgoCD
的 ApplicationSet
:
argo-apps.yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: apps-mycluster # ApplicationSet 名称,建议带集群名称后缀
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- git: # 通过当前 Git 仓库的 apps 目录下的子目录自动生成 Application
repoURL: git@yourgit.com:your-org/your-repo.git
revision: HEAD
directories:
- path: apps/*
template:
metadata:
name: "{{.path.basename}}-mycluster" # 自动创建的 Application 的名称格式为: 目录名-集群名
namespace: argocd
spec:
project: default
source:
repoURL: git@yourgit.com:your-org/your-repo.git
targetRevision: HEAD
path: "apps/{{.path.basename}}" # 自动生成的 Application 使用的 YAML 内容在对应子目录下
destination:
name: mycluster # Application 被部署的目的集群
syncPolicy:
automated:
prune: true
selfHeal: true
要点解析请看注释内容。