Skip to content

Conversation

a-hilaly
Copy link
Member

This PR introduces collections support in RGDs through a new forEach field, enabling dynamic creation of multiple resources based on iterative expressions.

  • Added forEach field to RGDs spec allowing iteration over both arrays and maps
  • Implemented CEL based collection evaluation with support for filtering and mapping
  • Added collection aware resource reconciliation in the controller
  • Introduced each context variables (item, index, length, key, value) for template access

Example usage:

resources:
  - id: replicaSet
    forEach: ${schema.spec.roles.filter(x, x.substring(0, 4) != 'test')}
    template:
      apiVersion: v1
      kind: Pod
      metadata:
        name: ${schema.spec.name + '-' + each.item}
      spec:
        containers:
          - name: ${schema.spec.name + '-' + each.item}
            image: ${schema.spec.image}

@a-hilaly a-hilaly added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 14, 2025
@barney-s
Copy link
Contributor

Do we want to start with a design doc first ?

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 12, 2025
@brandonjbjelland
Copy link

This is at the top of my wish list for kro - thank you for this work and anxiously awaiting its arrival!

@a-hilaly
Copy link
Member Author

a-hilaly commented Sep 20, 2025

@brandonjbjelland we're excited as well! i did open a proposal describing the collection semantics and possible use cases, your feedback would be highly valuable! => #679

@vast-raymond-page
Copy link

vast-raymond-page commented Sep 22, 2025

Instead of a "simple" case, can we have forEach be an array of collections as the only supported mechanic? I really like the idea of an array of collections to allow multiple iterators running over every combination of collections like discussed here:
#679 (comment)

  forEach:
    - collection: ${spec.regions}
      name: "region"
    - collection: ${spec.zones}
      name: "zone"
  template:
    kind: Pod
    metadata:
      name: ${'pod-' +region.entry+ '-' +  zone.entry}

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants