Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(app-of-apps): argoconfigs template #477

Merged
merged 7 commits into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
tongpu marked this conversation as resolved.
Show resolved Hide resolved

```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