|
1 | 1 | # List Generator
|
2 | 2 |
|
3 |
| -The List generator generates parameters based on any list of key/value pairs as long as the values are string values. In this example, we're targeting a local cluster named `engineering-dev`: |
| 3 | +The List generator generates parameters based on an arbitrary list of key/value pairs (as long as the values are string values). In this example, we're targeting a local cluster named `engineering-dev`: |
4 | 4 | ```yaml
|
5 | 5 | apiVersion: argoproj.io/v1alpha1
|
6 | 6 | kind: ApplicationSet
|
7 | 7 | metadata:
|
8 |
| - name: guestbook |
| 8 | + name: guestbook |
9 | 9 | spec:
|
10 |
| - generators: |
11 |
| - - list: |
12 |
| - elements: |
13 |
| - - cluster: engineering-dev |
14 |
| - url: https://kubernetes.default.svc |
15 |
| -# - cluster: engineering-prod |
16 |
| -# url: https://kubernetes.default.svc |
17 |
| -# foo: bar |
18 |
| - template: |
19 |
| - metadata: |
20 |
| - name: '{{cluster}}-guestbook' |
21 |
| - spec: |
22 |
| - project: default |
23 |
| - source: |
24 |
| - repoURL: https://github.com/argoproj-labs/applicationset.git |
25 |
| - targetRevision: HEAD |
26 |
| - path: examples/list-generator/guestbook/{{cluster}} |
27 |
| - destination: |
28 |
| - server: '{{url}}' |
29 |
| - namespace: guestbook |
| 10 | + generators: |
| 11 | + - list: |
| 12 | + elements: |
| 13 | + - cluster: engineering-dev |
| 14 | + url: https://kubernetes.default.svc |
| 15 | +# - cluster: engineering-prod |
| 16 | +# url: https://kubernetes.default.svc |
| 17 | +# foo: bar |
| 18 | + template: |
| 19 | + metadata: |
| 20 | + name: '{{cluster}}-guestbook' |
| 21 | + spec: |
| 22 | + project: default |
| 23 | + source: |
| 24 | + repoURL: https://github.com/argoproj-labs/applicationset.git |
| 25 | + targetRevision: HEAD |
| 26 | + path: examples/list-generator/guestbook/{{cluster}} |
| 27 | + destination: |
| 28 | + server: '{{url}}' |
| 29 | + namespace: guestbook |
30 | 30 | ```
|
31 | 31 | (*The full example can be found [here](https://github.com/argoproj-labs/applicationset/tree/master/examples/list-generator).*)
|
32 | 32 |
|
33 |
| -The List generator passes the `url` and `cluster` fields as parameters into the template. In this example, if one wanted to add a second element, we could uncomment the second element and the ApplicationSet controller would automatically target it with the defined application. |
| 33 | +In this example, the List generator passes the `url` and `cluster` fields as parameters into the template. If we wanted to add a second environment, we could uncomment the second element and the ApplicationSet controller would automatically target it with the defined application. |
| 34 | + |
| 35 | +With the ApplicationSet v0.1.0 release, one could *only* specify `url` and `cluster` element fields (plus arbitrary `values`). As of ApplicationSet v0.2.0, any key/value `element` pair is supported (which is also fully backwards compatible with the v0.1.0 form): |
| 36 | +```yaml |
| 37 | +spec: |
| 38 | + generators: |
| 39 | + - list: |
| 40 | + elements: |
| 41 | + # v0.1.0 form - requires cluster/url keys: |
| 42 | + - cluster: engineering-dev |
| 43 | + url: https://kubernetes.default.svc |
| 44 | + values: |
| 45 | + additional: value |
| 46 | + # v0.2.0+ form - does not require cluster/URL keys |
| 47 | + # (but they are still supported). |
| 48 | + - staging: "true" |
| 49 | + gitRepo: https://kubernetes.default.svc |
| 50 | +# (...) |
| 51 | +``` |
34 | 52 |
|
35 | 53 | !!! note "Clusters must be predefined in Argo CD"
|
36 | 54 | These clusters *must* already be defined within Argo CD, in order to generate applications for these values. The ApplicationSet controller does not create clusters within Argo CD (for instance, it does not have the credentials to do so).
|
0 commit comments