From 7de8cfe2aa55a786cb2adbe76416291f79bec585 Mon Sep 17 00:00:00 2001 From: "Randal S. Harisch" Date: Thu, 5 Oct 2023 23:37:05 -0600 Subject: [PATCH] chore: added argocd app-of-apps --- applications/Chart.yaml | 3 ++ applications/goghvideo.yaml | 27 ++++++++++++ applications/templates/app.yaml | 64 +++++++++++++++++++++++++++++ applications/templates/project.yaml | 36 ++++++++++++++++ applications/values.yaml | 41 ++++++++++++++++++ goghvideo-app-of-apps.yml | 21 ++++++++++ 6 files changed, 192 insertions(+) create mode 100644 applications/Chart.yaml create mode 100644 applications/goghvideo.yaml create mode 100644 applications/templates/app.yaml create mode 100644 applications/templates/project.yaml create mode 100644 applications/values.yaml create mode 100644 goghvideo-app-of-apps.yml diff --git a/applications/Chart.yaml b/applications/Chart.yaml new file mode 100644 index 0000000..b3a35c0 --- /dev/null +++ b/applications/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: applications +version: 0.1.0 diff --git a/applications/goghvideo.yaml b/applications/goghvideo.yaml new file mode 100644 index 0000000..37f10ed --- /dev/null +++ b/applications/goghvideo.yaml @@ -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 diff --git a/applications/templates/app.yaml b/applications/templates/app.yaml new file mode 100644 index 0000000..b17c8f3 --- /dev/null +++ b/applications/templates/app.yaml @@ -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 }} diff --git a/applications/templates/project.yaml b/applications/templates/project.yaml new file mode 100644 index 0000000..0bbcaec --- /dev/null +++ b/applications/templates/project.yaml @@ -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 }} + diff --git a/applications/values.yaml b/applications/values.yaml new file mode 100644 index 0000000..97462a8 --- /dev/null +++ b/applications/values.yaml @@ -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 + diff --git a/goghvideo-app-of-apps.yml b/goghvideo-app-of-apps.yml new file mode 100644 index 0000000..f49d84f --- /dev/null +++ b/goghvideo-app-of-apps.yml @@ -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