Post Selector all generators

The Selector allows to post-filter based on generated values using the Kubernetes common labelSelector format. In the example, the list generator generates a set of two application which then filter by the key value to only select the env with value staging:

Example: List generator + Post Selector

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: ApplicationSet
  3. metadata:
  4. name: guestbook
  5. spec:
  6. goTemplate: true
  7. goTemplateOptions: ["missingkey=error"]
  8. generators:
  9. - list:
  10. elements:
  11. - cluster: engineering-dev
  12. url: https://kubernetes.default.svc
  13. env: staging
  14. - cluster: engineering-prod
  15. url: https://kubernetes.default.svc
  16. env: prod
  17. selector:
  18. matchLabels:
  19. env: staging
  20. template:
  21. metadata:
  22. name: '{{.cluster}}-guestbook'
  23. spec:
  24. project: default
  25. source:
  26. repoURL: https://github.com/argoproj-labs/applicationset.git
  27. targetRevision: HEAD
  28. path: examples/list-generator/guestbook/{{.cluster}}
  29. destination:
  30. server: '{{.url}}'
  31. namespace: guestbook

The List generator + Post Selector generates a single set of parameters:

  1. - cluster: engineering-dev
  2. url: https://kubernetes.default.svc
  3. env: staging

It is also possible to use matchExpressions for more powerful selectors.

  1. spec:
  2. generators:
  3. - clusters: {}
  4. selector:
  5. matchExpressions:
  6. - key: server
  7. operator: In
  8. values:
  9. - https://kubernetes.default.svc
  10. - https://some-other-cluster