From 7a54350806b8785d0808652f8e23c5e33d20a28c Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Mon, 13 Dec 2021 14:38:12 +0100 Subject: [PATCH 1/4] docs(app-of-apps): argoconfigs template --- docs/argocd-app-of-apps.md | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/argocd-app-of-apps.md b/docs/argocd-app-of-apps.md index f90494466..dc34d891a 100644 --- a/docs/argocd-app-of-apps.md +++ b/docs/argocd-app-of-apps.md @@ -26,6 +26,45 @@ we consider valuable on most clusters. As with all the charts, `infra-apps` can depending on your exact situation, for example on Red Hat OpenShift you would typically not deploy the bundled ingress component. +## The `argoconfig` library chart + +Inspired by various `common` charts. The [`argoconfig` library chart](https://github.com/adfinis-sygroup/helm-charts/tree/master/charts/argoconfig) +helps us add keep charts that manage Argo CD `Application` resources generic to some degree. + +It provides the `argoconfig.application` helper function which scaffolds an `Application` resource like so. + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +# ... common.metadata +spec: + project: "default" + source: {} + destination: + server: "https://kubernetes.default.svc" + syncPolicy: {} +``` + +Our app-of-apps charts invoke the function in their individual `Application` templates. + +```yaml +{{ if .Values.example.enabled }} +{{ template "argoconfig.application" (list . "example-apps.example") }} +{{ end }} + +{{- define "example-apps.example" -}}{{- $app := unset .Values.example "enabled" -}}{{- $name := default $app.namespace $app.name -}} +metadata: + name: {{ template "common.fullname" . }}-{{ $name }} +spec: + {{- if $app.project }} + project: {{ $app.project | quote }} + {{- end }} + # ... more overriding, check any app-of-apps chart for an example +{{- end -}} +``` + +The first block in this example renders the `Application`, the second block injects a template used for rendering. + ## Further Info For now, these charts may be seen as an alternative to Argo CD ApplicationSets, [let us know](https://github.com/adfinis-sygroup/helm-charts/discussions) From ced356c3c4c03e3251c1ff3f6561b224b11bff3e Mon Sep 17 00:00:00 2001 From: Lucas Bickel <116588+hairmare@users.noreply.github.com> Date: Mon, 13 Dec 2021 17:01:06 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Lukas Grossar --- docs/argocd-app-of-apps.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/argocd-app-of-apps.md b/docs/argocd-app-of-apps.md index dc34d891a..bbb22e53f 100644 --- a/docs/argocd-app-of-apps.md +++ b/docs/argocd-app-of-apps.md @@ -29,9 +29,9 @@ component. ## The `argoconfig` library chart Inspired by various `common` charts. The [`argoconfig` library chart](https://github.com/adfinis-sygroup/helm-charts/tree/master/charts/argoconfig) -helps us add keep charts that manage Argo CD `Application` resources generic to some degree. +helps us keep charts that manage Argo CD `Application` resources generic to some degree. -It provides the `argoconfig.application` helper function which scaffolds an `Application` resource like so. +It provides the `argoconfig.application` helper function which scaffolds an `Application` resource like so: ```yaml apiVersion: argoproj.io/v1alpha1 @@ -45,7 +45,7 @@ spec: syncPolicy: {} ``` -Our app-of-apps charts invoke the function in their individual `Application` templates. +Our app-of-apps charts invoke the function in their individual `Application` templates: ```yaml {{ if .Values.example.enabled }} From b89b794df89b51c4c3ac0203ae45aee005aeb64c Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Tue, 14 Dec 2021 10:33:36 +0100 Subject: [PATCH 3/4] fixup! docs(app-of-apps): argoconfigs template --- docs/argocd-app-of-apps.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/argocd-app-of-apps.md b/docs/argocd-app-of-apps.md index bbb22e53f..f8f5f000c 100644 --- a/docs/argocd-app-of-apps.md +++ b/docs/argocd-app-of-apps.md @@ -63,7 +63,19 @@ spec: {{- end -}} ``` -The first block in this example renders the `Application`, the second block injects a template used for rendering. +The first block in this example renders the `Application`, the second block injects a template used for rendering. The first thing that +is done in the second block is to assign everything specific to an app to `$app` so it can be referenced in the template without needing +to write out the full `.Values.example` part over and over. + +In the above example the values section would contain a minimal example section as default: + +```yaml +example: + enabled: false + name: example + # ... more values, check any app-of-apps chart for an example + value: {} +``` ## Further Info From 5eb01d0de164acbde9a2511729370ef74e0ffb2e Mon Sep 17 00:00:00 2001 From: Lucas Bickel <116588+hairmare@users.noreply.github.com> Date: Tue, 14 Dec 2021 13:16:59 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Lukas Grossar --- docs/argocd-app-of-apps.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/argocd-app-of-apps.md b/docs/argocd-app-of-apps.md index f8f5f000c..d0923b27c 100644 --- a/docs/argocd-app-of-apps.md +++ b/docs/argocd-app-of-apps.md @@ -67,14 +67,14 @@ The first block in this example renders the `Application`, the second block inje is done in the second block is to assign everything specific to an app to `$app` so it can be referenced in the template without needing to write out the full `.Values.example` part over and over. -In the above example the values section would contain a minimal example section as default: +In the above example the `values.yaml` for an app-of-apps chart would contain a minimal section for an `example` application by default: ```yaml example: enabled: false name: example # ... more values, check any app-of-apps chart for an example - value: {} + values: {} ``` ## Further Info