kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

Could we add a shorthand for --field-selector in kubectl?

Open tnqn opened this issue 1 year ago • 10 comments

What happened?

I’m wondering if the --field-selector option is used frequently enough to justify a shorthand like -F. In our extension API server, we have a field that users need to specify to limit objects within a particular scope, but --field-selector feels a bit lengthy to type compared to the -l shorthand for label selectors. Would it make sense to add a shorthand for --field-selector?

Creating the issue to gather some feedback before introducing such a shorthand as suggested by @soltysh.

The original thread in sig-cli slack channel: https://kubernetes.slack.com/archives/C2GL57FJ4/p1725613426106679

cc @soltysh @apelisse

/sig cli

What did you expect to happen?

A shorthand can be used to filter objects by field selector, such as kubectl get FOO -F .spec.region=BAR.

How can we reproduce it (as minimally and precisely as possible)?

NONE

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

tnqn avatar Sep 09 '24 08:09 tnqn

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Sep 09 '24 08:09 k8s-ci-robot

It looks reasonable. However, I'm wondering whether this was intentional decision due to some reasons. /transfer kubectl

ardaguclu avatar Sep 09 '24 11:09 ardaguclu

/triage accepted Need to verify that there will not be collision between -f and -F. This will need to get tested across windows/macOS/various linux distros.

mpuckett159 avatar Sep 11 '24 16:09 mpuckett159

This is totally parsed by the program, as opposed to the file path that is usually parsed by the kernel/operating system.

apelisse avatar Sep 11 '24 16:09 apelisse

Thank you all for your feedback.

It looks reasonable. However, I'm wondering whether this was intentional decision due to some reasons.

@ardaguclu, I checked https://github.com/kubernetes/kubernetes/pull/50140 which added the flag and didn't find any discussion about the shorthand, I guess it wasn't intentional.

Need to verify that there will not be collision between -f and -F. This will need to get tested across windows/macOS/various linux distros.

@mpuckett159, as @apelisse explains, this is parsed by the program so the flag names are case-sensitive, otherwise the command kubectl get -l <selector> -L <label> would fail.

I created https://github.com/kubernetes/kubernetes/pull/127345 to implement it, could you please take a look?

tnqn avatar Sep 13 '24 14:09 tnqn

/kind feature

soltysh avatar Sep 13 '24 14:09 soltysh

Apologies I misunderstood and we need to wait for more evidence for this before accepting. This issue should be fore gathering more feedback. Sorry for the churn/misunderstanding.

mpuckett159 avatar Sep 14 '24 23:09 mpuckett159

JFYI https://github.com/kubernetes/kubernetes/pull/127345 was closed due to inactivity . It should be reopened if it is still awaiting reviews and the feature is useful.

Ritikaa96 avatar Feb 20 '25 12:02 Ritikaa96

JFYI kubernetes/kubernetes#127345 was closed due to inactivity . It should be reopened if it is still awaiting reviews and the feature is useful.

Reopened it.

tnqn avatar Feb 20 '25 14:02 tnqn

Let's keep the PR closed, and gauge the interest behind this particular feature. As Marly pointed out earlier there are several considerations (overlap with -f, interest to name the few) that I'd like to learn more, before we make the final decision.

/triage needs-information

soltysh avatar Apr 30 '25 11:04 soltysh

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 29 '25 12:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Aug 28 '25 12:08 k8s-triage-robot