kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Select/Exclude KRM resources passed to KRM functions

Open jashandeep-sohi opened this issue 1 year ago • 1 comments
trafficstars

Eschewed features

  • [X] This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

Allow specifying a selector to include or exclude KRM resources passed to a KRM function in the config.kubernetes.io/function spec annotation. Something similar to how KPT lets you do that, https://kpt.dev/book/04-using-functions/01-declarative-function-execution?id=specifying-selectors

For example, to only pass KRMs of kind Deployment:

    config.kubernetes.io/function: |
      container:
        image: krm-fn-image
      select:
        kind: Deployment

Or, to pass everything but all Deployment:

    config.kubernetes.io/function: |
      container:
        image: krm-fn-image
      exclude:
        kind: Deployment

select & exclude would naturally be mutually exclusive.

Why is this needed?

Sometimes you only want KRM functions to run on a subset of resources.

Can you accomplish the motivating task without this feature, and if so, how?

Perhaps. Every KRM function would have to implement some kind of selector/exclude logic.

What other solutions have you considered?

A wrapper exec KRM function that does the filtering and then calls the original KRM function.

Anything else we should know?

No response

Feature ownership

  • [X] I am interested in contributing this feature myself! 🎉

jashandeep-sohi avatar Oct 10 '24 22:10 jashandeep-sohi