kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.75k stars 894 forks source link

Support for ignoring files when using `kubectl apply -f .` #1583

Closed wiktor-k closed 2 months ago

wiktor-k commented 2 months ago

What would you like to be added:

Support for ignoring files when using kubectl apply -f ., e.g. by introducing the .kubeignore file (similar to .gitignore, .dockerignore).

Why is this needed:

I'm using ApplySets to manage a consistent state of the cluster that matches a directory:

KUBECTL_APPLYSET=true kubectl apply -f . --recursive --prune --applyset=apps --namespace apps

And in the same directory I need to keep a couple of files that help in development (e.g. kubelinter). Currently the output is:

service/currencies unchanged
cronjob.batch/turn-checker unchanged
...
error: error validating ".kube-linter.yml":
error validating data: [apiVersion not set, kind not set];
if you choose to ignore these errors, turn validation off with --validate=false

Of course I don't want to disable the validation.

Alternative solution would be ignoring hidden files (prefixed with a .).

(I've searched the issues and except for this ticket there were no matches).

Thanks for your time and work on this great tool! :wave:

k8s-ci-robot commented 2 months ago

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
ah8ad3 commented 2 months ago

I am not sure but think you can achieve this by using Kustomize. But seems like a good idea to have this option too, +1 for me, but IDK about limitation there might be some. I'll try to ask this in SIG's meeting next week.

mpuckett159 commented 2 months ago

/close In addition to kustomize this could also be accomplished via shell scripting or a plugin. Closing this issue as it is possible using other tooling.

k8s-ci-robot commented 2 months ago

@mpuckett159: Closing this issue.

In response to [this](https://github.com/kubernetes/kubectl/issues/1583#issuecomment-2075467939): >/close >In addition to kustomize this could also be accomplished via shell scripting or a plugin. Closing this issue as it is possible using other tooling. Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.