feat(argocd-apps): Add ArgoCD ApplicationSet (#1521)

* Add ArgoCD ApplicationSet

Signed-off-by: toyamagu <toyamagu2021@gmail.com>
Signed-off-by: Petr Drastil <petr.drastil@gmail.com>
Co-authored-by: Petr Drastil <petr.drastil@gmail.com>
This commit is contained in:
toyamagu 2022-10-12 17:31:54 +09:00 committed by GitHub
parent 9b2f24514c
commit 14d2b8313e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 171 additions and 4 deletions

View file

@ -59,10 +59,11 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
with:
config: .github/configs/kind-config.yaml
- name: Deploy latest ArgoCD CRDs when testing ArgoCD extensions
if: |
contains(steps.list-changed.outputs.changed_charts, 'argocd-image-updater')
contains(steps.list-changed.outputs.changed_charts, 'argocd-image-updater') ||
contains(steps.list-changed.outputs.changed_charts, 'argocd-apps')
run: |
helm repo add dandydeveloper https://dandydeveloper.github.io/charts/
helm dependency build charts/argo-cd/

View file

@ -2,7 +2,7 @@ apiVersion: v2
name: argocd-apps
description: A Helm chart for managing additional Argo CD Applications and Projects
type: application
version: 0.0.1
version: 0.0.2
home: https://github.com/argoproj/argo-helm
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
keywords:
@ -14,4 +14,4 @@ maintainers:
url: https://argoproj.github.io/
annotations:
artifacthub.io/changes: |
- "[Added]: Add additional Applications and Projects"
- "[Added]: Add ApplicationSets"

View file

@ -25,6 +25,7 @@ $ helm install my-release argo/argocd-apps
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| applications | list | `[]` (See [values.yaml]) | Deploy Argo CD Applications within this helm release |
| applicationsets | list | `[]` (See [values.yaml]) | Deploy Argo CD ApplicationSets within this helm release |
| projects | list | `[]` (See [values.yaml]) | Deploy Argo CD Projects within this helm release |
----------------------------------------------

View file

@ -0,0 +1,45 @@
# Test with applicationsets
applicationsets:
- name: guestbook
namespace: default # Only for test purpose.
additionalLabels: {}
additionalAnnotations: {}
# See PR #10026 (ArgoCD v2.5 or later)
# goTemplate: false
generators:
- git:
repoURL: https://github.com/argoproj/argocd-example-apps.git
revision: HEAD
directories:
- path: guestbook
- path: kustomize-*
template:
metadata:
name: '{{path.basename}}'
labels: {}
annotations: {}
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: HEAD
path: '{{path}}'
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: false
selfHeal: false
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers:
- /spec/replicas
info:
- name: url
value: https://argoproj.github.io/
syncPolicy:
# Set Application finalizer
preserveResourcesOnDeletion: false

View file

@ -0,0 +1,73 @@
{{- range .Values.applicationsets }}
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
{{- with .additionalAnnotations }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- with .additionalLabels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .name }}
{{- with .namespace }}
namespace: {{ . }}
{{- end }}
spec:
{{- if hasKey . "goTemplate" }}
goTemplate: {{ .goTemplate }}
{{- end }}
{{- with .generators }}
generators:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .syncPolicy }}
syncPolicy:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .template }}
template:
{{- with .metadata }}
metadata:
{{- with .annotations }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | squote }}
{{- end }}
{{- end }}
{{- with .labels }}
labels:
{{- toYaml . | nindent 8 }}
{{- end }}
name: {{ .name | squote }}
{{- with .namespace }}
namespace: {{ . | squote }}
{{- end }}
{{- end }}
{{- with .spec }}
spec:
project: {{ tpl .project $ }}
source:
{{- toYaml .source | nindent 8 }}
destination:
{{- toYaml .destination | nindent 8 }}
{{- with .syncPolicy }}
syncPolicy:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .ignoreDifferences }}
ignoreDifferences:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .info }}
info:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
{{- end }}
{{- end }}

View file

@ -74,3 +74,50 @@ projects: []
# manualSync: true
# signatureKeys:
# - keyID: ABCDEF1234567890
# -- Deploy Argo CD ApplicationSets within this helm release
# @default -- `[]` (See [values.yaml])
## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/
applicationsets: []
# - name: guestbook
# namespace: argocd
# additionalLabels: {}
# additionalAnnotations: {}
# # See PR #10026 (ArgoCD v2.5 or later)
# # goTemplate: false
# generators:
# - git:
# repoURL: https://github.com/argoproj/argocd-example-apps.git
# revision: HEAD
# directories:
# - path: guestbook
# - path: kustomize-*
# template:
# metadata:
# name: '{{path.basename}}'
# labels: {}
# annotations: {}
# spec:
# project: default
# source:
# repoURL: https://github.com/argoproj/argocd-example-apps.git
# targetRevision: HEAD
# path: '{{path}}'
# destination:
# server: https://kubernetes.default.svc
# namespace: default
# syncPolicy:
# automated:
# prune: false
# selfHeal: false
# ignoreDifferences:
# - group: apps
# kind: Deployment
# jsonPointers:
# - /spec/replicas
# info:
# - name: url
# value: https://argoproj.github.io/
# syncPolicy:
# # Set Application finalizer
# preserveResourcesOnDeletion: false