kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.83k stars 913 forks source link

Help to avoid accidental deletion of persistent volumes #1573

Closed m-dm closed 6 months ago

m-dm commented 6 months ago

Hi,

today I mistakenly ran this command:

kubectl delete pv -n redacted --all

instead of kubectl delete pvc -n redacted --all

so just by skipping a key and of course, not enough attention, bad luck, etc.. I got myself into a sticky situation.

After fixing my mistake, i thought that could be useful that kubectl returns an error if a namespace is specified in a command related to a non-namespaced resource, like in my case.

Please forgive me if I'm wrong, as you saw i'm still a kubernetes novice. And also please sorry my bad english.

Thanks Regards

k8s-ci-robot commented 6 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.
ardaguclu commented 6 months ago

This is well-known issue and duplicate of https://github.com/kubernetes/kubectl/issues/1365. Unfortunately, we can't change the default behavior as it breaks older clusters. Suggested workaround is using --interactive flag in delete command https://github.com/kubernetes/kubectl/issues/1365#issuecomment-1422998174

m-dm commented 6 months ago

ok, thank you!

m-dm commented 6 months ago

duplicate of https://github.com/kubernetes/kubectl/issues/1365