chore: added argocd app-of-apps

This commit is contained in:
2023-10-05 23:37:05 -06:00
parent 546a360825
commit 7de8cfe2aa
6 changed files with 192 additions and 0 deletions

3
applications/Chart.yaml Normal file
View File

@@ -0,0 +1,3 @@
apiVersion: v2
name: applications
version: 0.1.0

View File

@@ -0,0 +1,27 @@
envName: goghvideo
envSuffix: "" #Should be empty if this is the cluster's main workload namespace
default:
app:
project: default
destination:
namespace: goghvideo
server: https://kubernetes.default.svc
source:
targetRevision: HEAD
#projects:
# campaign-service:
# description: 'Playbook execution and scheduling'
# sourceRepos:
# - https://github.com/symend-operations/helmspike.git
applications:
notification:
enabled: true
enableAutoSync: true
enableArgoNotifications: false
cdEnabled: false
imageList:
- app=quay01.ipa.endofday.com/goghvideo/notification:^v0.1.x
imageNamesAndTags:
argocd-image-updater.argoproj.io/app.helm.image-name: app.image.repository
argocd-image-updater.argoproj.io/app.helm.image-tag: appVersionOverride

View File

@@ -0,0 +1,64 @@
{{- range $key,$val := .Values.applications }}
{{- /*
in order to use tpl within a range, _and_ have the key/val available to sub-templates,
need to add some variables to the root context.
*/ -}}
{{- $_ := set $ "curAppName" (print $.Values.envName "-" $key) }}
{{- if $val.enabled }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
{{- if $.Values.envSuffix }}
name: {{ printf "%s-%s" $key $.Values.envSuffix }}
{{- else }}
name: {{ $key }}
{{- end }}
namespace: {{ $.Values.default.app.metadata.namespace }}
annotations:
{{- if default false $val.cdEnabled }}
{{- with $val.imageList }}
argocd-image-updater.argoproj.io/image-list: |-
{{ join ", " . }}
{{- end }}
{{- toYaml $val.imageNamesAndTags | nindent 4 }}
argocd-image-updater.argoproj.io/git-branch: main
argocd-image-updater.argoproj.io/write-back-method: git:secret:argocd/git-creds
{{- end }}
{{- if default false $val.enableArgoNotifications }}
notifications.argoproj.io/subscribe.on-deployed.slack: {{ $.Values.argoNotificationsSlackChannel }}
notifications.argoproj.io/subscribe.on-health-degraded.slack: {{ $.Values.argoNotificationsSlackChannel }}
notifications.argoproj.io/subscribe.on-sync-failed.slack: {{ $.Values.argoNotificationsSlackChannel }}
{{- end }}
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: {{ $val.destination.namespace | default $.Values.default.app.destination.namespace | required (printf "No destination.namespace specified for %s" $key ) }}
server: {{ $val.destination.server | default $.Values.default.app.destination.server | required (printf "No destination.server specified for %s" $key ) }}
{{- if $.Values.projectOverride }}
project: {{ $.Values.projectOverride }}
{{- else }}
project: {{ $val.project | default $.Values.default.app.project | required (printf "No project specified for %s" $key ) }}
{{- end }}
{{- if $val.enableAutoSync | default $.Values.default.app.enableAutoSync }}
syncPolicy:
automated:
prune: {{ $val.autoSyncPrune | default $.Values.default.app.autoSyncPrune | default true }}
{{- end }}
source:
path: {{ tpl $val.source.path $ }}
repoURL: {{ $val.source.repoURL | default $.Values.default.app.source.repoURL | required (printf "No source.repoURL specified for %s" $key ) }}
targetRevision: {{ $.Values.default.app.source.targetRevision | default $val.source.targetRevision | required (printf "No source.targetRevision specified for %s" $key ) }}
{{- if $val.source.extraSourceFields }}
{{ tpl $val.source.extraSourceFields $ | indent 4 }}
{{- else if $.Values.default.app.source.extraSourceFields }}
{{ tpl $.Values.default.app.source.extraSourceFields $ | indent 4 }}
{{- end }}
{{- if $val.extraFields }}
{{ tpl $val.extraFields $ | indent 2 }}
{{- else if $.Values.default.app.extraFields }}
{{ tpl $.Values.default.app.extraFields $ | indent 2 }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,36 @@
{{- if not $.Values.projectOverride }}
{{- range $key,$val := .Values.projects }}
{{- /*
in order to use tpl within a range, _and_ have the key/val available to sub-templates,
need to add some variables to the root context.
*/ -}}
{{- $_ := set $ "curProjName" (print $.Values.envName "-" $key) }}
---
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: {{ $key }}
spec:
{{- if $val.extraFields }}
{{ tpl $val.extraFields $ | indent 2 }}
{{- end }}
description: {{ tpl $val.description $ }}
sourceRepos:
{{ toYaml $val.sourceRepos | indent 4 }}
{{- if $val.roles }}
roles:
{{ tpl $val.roles $ | indent 4 }}
{{- else if $.Values.default.project.roles }}
roles:
{{ tpl $.Values.default.project.roles $ | indent 4 }}
{{- end }}
{{- if $val.destinations }}
destinations:
{{ tpl $val.destinations $ | indent 4 }}
{{- else if $.Values.default.project.destinations }}
destinations:
{{ tpl $.Values.default.project.destinations $ | indent 4 }}
{{- end }}
{{- end }}
{{- end }}

41
applications/values.yaml Normal file
View File

@@ -0,0 +1,41 @@
# your override should supply an envName
envName: null
envSuffix: null
# if set, override all Applications to use this project
projectOverride: null
default:
app:
metadata:
namespace: argocd
enableAutoSync: null
autoSyncPrune: true
destination:
namespace: null
server: null
project: default
source:
chart: null
repoURL: git@git-ssh.ipa.endofday.com:/goghvideo/helm.git
targetRevision: HEAD
extraSourceFields: |
helm:
valueFiles:
- values.yaml
applications:
notification:
enableAutoSync: true
autoSyncPrune: true
destination:
namespace: null
server: null
project: default
source:
path: charts/notification
repoURL: null
targetRevision: HEAD

21
goghvideo-app-of-apps.yml Normal file
View File

@@ -0,0 +1,21 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: goghvideo-applications
namespace: argocd
spec:
destination:
namespace: argocd
server: https://kubernetes.default.svc
project: default
source:
path: applications
repoURL: git@git-ssh.ipa.endofday.com:/goghvideo/helm.git
targetRevision: HEAD
helm:
valueFiles:
- goghvideo.yaml
syncPolicy:
automated:
selfHeal: true
prune: true