Skip to content

kpt fn render|eval should support excluding resources from function input #2930

@droot

Description

@droot

CUJ

kpt fn render and kpt fn eval supports mechanism to target resources to apply function on. For example:

# Apply set-labels on resources of kind Deployment and belonging to group apps
$ kpt fn eval [PKG_DIR] -i set-labals:v0.1.5 --match-group apps --match-kind Deployment 

Declaratively, for example, apply set-labels on resources with group apps and kind Deployment.

# excerpts from Kptfile

...

pipeline:
  mutators:
   - image: set-labels:v0.1.5
     selectors:
       - group: apps
          kind: Deployment

Sometimes users want to exclude set of resources from function's target. For ex. apply this function on all resources except the ones with kind Kptfile or apply this label on all the deployments except with a specific name.

This will become especially important as we allow functionConfigs and Kptfile to be included in function input by default in kpt fn commands.

Proposal

Imperative workflow:

# apply set-labels to all the deployments except a given name
$ kpt fn eval [PKG_DIR] -i set-labels:v0.1.5 --match-kind Deployment --exclude-name some-name

# apply set-labels on resources belonging to apps group except kind StatefulSet
$ kpt fn eval [PKG_DIR] -i set-labels:v0.1.5 --match-group apps --exclude-kind StatefulSet

Declarative workflow:

Introduce exclude selectors.

# apply set-labels on all resources except with kind `Kptfile` or group `apps`
...
pipeline:
  mutators:
   - image: set-labels:v0.1.5
     exclude:
       - kind: Kptfile
       - group: apps

Alternatives names for exclude: except, reject

It will also be nice to have a way syntactic sugar for select or exclude all local-configs (resources with a config.kubernetes.io/local-config: "true" annotation).

Metadata

Metadata

Assignees

Labels

area/hydrateenhancementNew feature or requestp0triagedIssue has been triaged by adding an `area/` label

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions