feat(argocd-apps): Generate application, applicationset, project with template (#2025)
* add template for application Signed-off-by: Joe Lee <lj_2005@163.com> * update version Signed-off-by: Joe Lee <lj_2005@163.com> * fix issue Signed-off-by: Joe Lee <lj_2005@163.com> * add example for applicationsetTemplates Signed-off-by: Joe Lee <lj_2005@163.com> * fix issue Signed-off-by: Joe Lee <lj_2005@163.com> * merge each of items into one Signed-off-by: Joe Lee <lj_2005@163.com> * update readme Signed-off-by: Joe Lee <lj_2005@163.com> * update doc Signed-off-by: Joe Lee <lj_2005@163.com> * update version Signed-off-by: Joe Lee <lj_2005@163.com> * add template for application Signed-off-by: Joe Lee <lj_2005@163.com> * update version Signed-off-by: Joe Lee <lj_2005@163.com> * fix issue Signed-off-by: Joe Lee <lj_2005@163.com> * fix issue Signed-off-by: Joe Lee <lj_2005@163.com> * merge each of items into one Signed-off-by: Joe Lee <lj_2005@163.com> * move itemTemplates to new file Signed-off-by: Joe Lee <lj_2005@163.com> * discard change for applications.yaml Signed-off-by: Joe Lee <lj_2005@163.com> --------- Signed-off-by: Joe Lee <lj_2005@163.com>
This commit is contained in:
parent
7347a5d781
commit
c3cfd49e96
5 changed files with 144 additions and 2 deletions
|
@ -2,7 +2,7 @@ apiVersion: v2
|
||||||
name: argocd-apps
|
name: argocd-apps
|
||||||
description: A Helm chart for managing additional Argo CD Applications and Projects
|
description: A Helm chart for managing additional Argo CD Applications and Projects
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.1.0
|
||||||
home: https://github.com/argoproj/argo-helm
|
home: https://github.com/argoproj/argo-helm
|
||||||
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
|
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
|
||||||
keywords:
|
keywords:
|
||||||
|
@ -18,4 +18,4 @@ annotations:
|
||||||
url: https://argoproj.github.io/argo-helm/pgp_keys.asc
|
url: https://argoproj.github.io/argo-helm/pgp_keys.asc
|
||||||
artifacthub.io/changes: |
|
artifacthub.io/changes: |
|
||||||
- kind: added
|
- kind: added
|
||||||
description: Introduce chart signing
|
description: Generate application, applicationset, project with template
|
||||||
|
|
|
@ -31,6 +31,7 @@ $ helm install my-release argo/argocd-apps
|
||||||
| applications | list | `[]` (See [values.yaml]) | Deploy Argo CD Applications within this helm release |
|
| 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 |
|
| applicationsets | list | `[]` (See [values.yaml]) | Deploy Argo CD ApplicationSets within this helm release |
|
||||||
| extensions | list | `[]` (See [values.yaml]) | Deploy Argo UI Extensions within this helm release |
|
| extensions | list | `[]` (See [values.yaml]) | Deploy Argo UI Extensions within this helm release |
|
||||||
|
| itemTemplates | list | `[]` (See [values.yaml]) | Deploy Argo CD Applications/ApplicationSets/Projects within this helm release |
|
||||||
| projects | list | `[]` (See [values.yaml]) | Deploy Argo CD Projects within this helm release |
|
| projects | list | `[]` (See [values.yaml]) | Deploy Argo CD Projects within this helm release |
|
||||||
|
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
61
charts/argocd-apps/ci/item-templates.yaml
Normal file
61
charts/argocd-apps/ci/item-templates.yaml
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
itemTemplates:
|
||||||
|
- items:
|
||||||
|
- name: my-appset
|
||||||
|
generators: &generators
|
||||||
|
- list:
|
||||||
|
elements:
|
||||||
|
- cluster: engineering-dev
|
||||||
|
url: https://1.2.3.4
|
||||||
|
- cluster: engineering-prod
|
||||||
|
url: https://2.4.6.8
|
||||||
|
- cluster: finance-preprod
|
||||||
|
url: https://9.8.7.6
|
||||||
|
template:
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: ApplicationSet
|
||||||
|
metadata:
|
||||||
|
name: "{{ .name }}"
|
||||||
|
spec:
|
||||||
|
generators: *generators
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: "{{`{{cluster}}`}}-guestbook"
|
||||||
|
spec:
|
||||||
|
project: my-project
|
||||||
|
source:
|
||||||
|
repoURL: https://github.com/infra-team/cluster-deployments.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
path: guestbook/{{`{{cluster}}`}}
|
||||||
|
destination:
|
||||||
|
server: "{{`{{cluster}}`}}"
|
||||||
|
namespace: guestbook
|
||||||
|
- items:
|
||||||
|
- name: my-appset
|
||||||
|
generators:
|
||||||
|
- list:
|
||||||
|
elements:
|
||||||
|
- cluster: engineering-dev
|
||||||
|
url: https://1.2.3.4
|
||||||
|
- cluster: engineering-prod
|
||||||
|
url: https://2.4.6.8
|
||||||
|
- cluster: finance-preprod
|
||||||
|
url: https://9.8.7.6
|
||||||
|
template: |-
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: ApplicationSet
|
||||||
|
metadata:
|
||||||
|
name: {{ .name }}
|
||||||
|
spec:
|
||||||
|
generators: {{ toYaml .generators | nindent 4 }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: '{{`{{cluster}}`}}-guestbook'
|
||||||
|
spec:
|
||||||
|
project: my-project
|
||||||
|
source:
|
||||||
|
repoURL: https://github.com/infra-team/cluster-deployments.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
path: guestbook/{{`{{cluster}}`}}
|
||||||
|
destination:
|
||||||
|
server: '{{`{{cluster}}`}}'
|
||||||
|
namespace: guestbook
|
15
charts/argocd-apps/templates/item-templates.yaml
Normal file
15
charts/argocd-apps/templates/item-templates.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{{- range .Values.itemTemplates }}
|
||||||
|
{{- if kindIs "string" .template }}
|
||||||
|
{{- $template := .template -}}
|
||||||
|
{{- range .items }}
|
||||||
|
---
|
||||||
|
{{ tpl $template (set . "Template" $.Template) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $template := .template | toYaml -}}
|
||||||
|
{{- range .items }}
|
||||||
|
---
|
||||||
|
{{ tpl $template (set . "Template" $.Template) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
|
@ -133,6 +133,71 @@ applicationsets: []
|
||||||
# # Set Application finalizer
|
# # Set Application finalizer
|
||||||
# preserveResourcesOnDeletion: false
|
# preserveResourcesOnDeletion: false
|
||||||
|
|
||||||
|
# -- Deploy Argo CD Applications/ApplicationSets/Projects within this helm release
|
||||||
|
# @default -- `[]` (See [values.yaml])
|
||||||
|
## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/
|
||||||
|
itemTemplates: []
|
||||||
|
# - items:
|
||||||
|
# - name: my-appset
|
||||||
|
# generators: &generators
|
||||||
|
# - list:
|
||||||
|
# elements:
|
||||||
|
# - cluster: engineering-dev
|
||||||
|
# url: https://1.2.3.4
|
||||||
|
# - cluster: engineering-prod
|
||||||
|
# url: https://2.4.6.8
|
||||||
|
# - cluster: finance-preprod
|
||||||
|
# url: https://9.8.7.6
|
||||||
|
# template:
|
||||||
|
# apiVersion: argoproj.io/v1alpha1
|
||||||
|
# kind: ApplicationSet
|
||||||
|
# metadata:
|
||||||
|
# name: "{{ .name }}"
|
||||||
|
# spec:
|
||||||
|
# generators: *generators
|
||||||
|
# template:
|
||||||
|
# metadata:
|
||||||
|
# name: "{{`{{cluster}}`}}-guestbook"
|
||||||
|
# spec:
|
||||||
|
# project: my-project
|
||||||
|
# source:
|
||||||
|
# repoURL: https://github.com/infra-team/cluster-deployments.git
|
||||||
|
# targetRevision: HEAD
|
||||||
|
# path: guestbook/{{`{{cluster}}`}}
|
||||||
|
# destination:
|
||||||
|
# server: "{{`{{cluster}}`}}"
|
||||||
|
# namespace: guestbook
|
||||||
|
# - items:
|
||||||
|
# - name: my-appset
|
||||||
|
# generators:
|
||||||
|
# - list:
|
||||||
|
# elements:
|
||||||
|
# - cluster: engineering-dev
|
||||||
|
# url: https://1.2.3.4
|
||||||
|
# - cluster: engineering-prod
|
||||||
|
# url: https://2.4.6.8
|
||||||
|
# - cluster: finance-preprod
|
||||||
|
# url: https://9.8.7.6
|
||||||
|
# template: |-
|
||||||
|
# apiVersion: argoproj.io/v1alpha1
|
||||||
|
# kind: ApplicationSet
|
||||||
|
# metadata:
|
||||||
|
# name: {{ .name }}
|
||||||
|
# spec:
|
||||||
|
# generators: {{ toYaml .generators | nindent 4 }}
|
||||||
|
# template:
|
||||||
|
# metadata:
|
||||||
|
# name: '{{`{{cluster}}`}}-guestbook'
|
||||||
|
# spec:
|
||||||
|
# project: my-project
|
||||||
|
# source:
|
||||||
|
# repoURL: https://github.com/infra-team/cluster-deployments.git
|
||||||
|
# targetRevision: HEAD
|
||||||
|
# path: guestbook/{{`{{cluster}}`}}
|
||||||
|
# destination:
|
||||||
|
# server: '{{`{{cluster}}`}}'
|
||||||
|
# namespace: guestbook
|
||||||
|
|
||||||
# -- Deploy Argo UI Extensions within this helm release
|
# -- Deploy Argo UI Extensions within this helm release
|
||||||
# @default -- `[]` (See [values.yaml])
|
# @default -- `[]` (See [values.yaml])
|
||||||
## This function in tech preview stage, do expect unstability or breaking changes in newer versions. Bump image.tag if necessary.
|
## This function in tech preview stage, do expect unstability or breaking changes in newer versions. Bump image.tag if necessary.
|
||||||
|
|
Loading…
Reference in a new issue