Skip to content

Commit

Permalink
docs(app-of-apps): argoconfigs template (#477)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Grossar <[email protected]>
  • Loading branch information
hairmare and tongpu authored Dec 14, 2021
1 parent b6c87f1 commit 91882df
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions docs/argocd-app-of-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,57 @@ 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 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. 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.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
values: {}
```

## 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)
Expand Down

0 comments on commit 91882df

Please sign in to comment.