kptdev / kpt

Automate Kubernetes Configuration Editing
https://kpt.dev
Apache License 2.0
1.7k stars 228 forks source link

fn apply setters allow to specify an ignore-pattern #2607

Open oswald0071 opened 2 years ago

oswald0071 commented 2 years ago

Describe your problem

I do have config-files which are mounted through a config-map-generator into a container and have the ending yaml (for whatever reason, json works). These files should not be considered by the fn-apply-setters because these files are not matching the kubernetes format and an error occurs during the rendering.

Error: input resource list must contain only KRM resources: upstream/config/prometheus-jmx.yaml: resource must have 'apiVersion'.

Therefore, I implemented a .krmignore file to ignore this file and the rendering works just as intended. But unfortunately other functions like kpt pkg update are now ignoring these files as well.

A possible solution would be, if I can set the ignore patterns closer to the kpt fn render function (i.e. at the Kustomization-File, or directly at the fn-apply-setters.yaml) in order to restrict the filtering of the files directly to the function instead of applying the file-filter to every kpt call.

Maybe there is already a solution for this, but I was not able to find it in the documentation.

Thank you.

EDIT: Version that I'm using is 1.0.0-beta.9 or self installed (current version) The issue is only occuring during kpt pkg update. If I delete the package and reinstall it with kpt pkg get the file exists.

droot commented 2 years ago

Therefore, I implemented a .krmignore file to ignore this file and the rendering works just as intended. But unfortunately other functions like kpt pkg update are now ignoring these files as well.

I think this is working as expected, kpt pkg update will ignore resources specified by file .krmignore. Ignore here means, kpt pkg update should treat prometheus-jmx.yaml file as a blob and replace the local copy with the upstream. Is that what you are seeing @oswald0071 ?

/cc @phanimarupaka

oswald0071 commented 2 years ago

I also think for kpt pkg upgrade works as intended. But I think there should be a way to exclude certain files only during the application of a function. In my case, I would prefer to not have a .krmignore and specify an ignore pattern somehow just for the kpt fn render function or even only for the fn-apply-setters function. That means that I would like to have an option to ignore certain files only during specific operations.