kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

kubectl CLI should more consistently and concisely convey discovery

Open smarterclayton opened this issue 8 years ago • 8 comments

Moved from kubernetes/kubernetes#53387


Now that discovery is complete as an API, and CRD and aggregation are in heavy use, we need to make some minor tweaks to kubectl to improve discoverability of apis from clients.

Common issues:

  1. I want to see all resources that I might be able to create
  2. I want to be able to disambiguate conflicting resources
  3. I want to distinguish between cluster scoped and non-cluster scoped resources
  4. I want an equivalent to the all shortcut that is actually all resource types that are namespace scoped

We want to orient brand new users to kubectl from a config perspective into:

  1. what can i get
  2. if i want to create a config resource, how do i specify it (explain, which could be better)
  3. i want to know what a resource is for

Some thoughts:

  1. kubectl api-versions is too simple, and needs to be better or removed
  2. There should be a command that makes it easy to see the list of:
    1. all namespace scoped resources
    2. all cluster scoped resources
    3. the shortcuts of those resources
    4. what the resource does (potentially as a -v option)
    5. a brief discussion of how to deal with version conflicting names (pod v1beta.special.bar and pod v1)
    6. potentially what versions exist for those resources
  3. explain and get should suggest that command when you specify something it doesn't recognize
  4. We could piggyback this into get except discovery resources aren't quite a format API, so it would be somewhat hacky. However, get and describe already work so a few special cases aren't terrible (we did reserve APIGroupList v1 and APIGroup v1)

Hypothetical

$ kubectl get apigroups
NAME      VERSIONS  RESOURCES
autoscaling v1         horizontalpodautoscaler

$ kubectl describe apis
API Groups
  autoscaling:
    v1: 
       Resources: horizontalpodautoscaler
    v2:
       ...

$ kubectl get apis
NAME      VERSIONS  RESOURCES
autoscaling v1         horizontalpodautoscaler

$ kubectl apis
GROUP      VERSIONS  RESOURCES
autoscaling v1         horizontalpodautoscaler

$ kubectl apis --group=autoscaling --version=v1
GROUP      VERSIONS  RESOURCES
autoscaling v1         horizontalpodautoscaler

$ kubectl explain
error: You must select a resource type to explain:

   Nicely formatted two column table - one for namespace scoped and one for cluster scoped

It should be easy to select all namespaced resources from a command - we should add:

$ kubectl get all-namespaced --all
$ kubectl describe all-namespaced
$ kubectl delete all-resources --all

We can't change all because of backwards compatibility (anyone with kubectl delete all --all would be broken if we change what all covers), but also because it's deliberately short to remain easy to type for end users.


This is really annoying now that I'm dealing with more and more groups.

Explain should tell me what group something is I need to be able to see info on a given resource type in the exact form that I would specify it to get (the so called "resource-arg" form resource.version.group). I.e. "I got an error that told me this resource doesn't do what I think - how do i find out more about it". Error messages need to do a better job of returning a discoverable type (for 2) - right now we're doing either the struct print for many of them or the GroupVersionResource.String() method which is not an accepted form. I think this is the #1 issue dealing with extensions - no place to go to find them, no way to know how to use them in kubectl, no way to check that the ones I care about are registered.

Use cases:

When I as a user get errors about mismatches between what I typed and what is available on the server, I need to discover what is on the server As a user, I expect to get canonical representations of resources so as to avoid having to explain how to transform the representations myself


We already have kubectl api-versions and there was a PR to add kubectl api-resources. But when I think about the operations that these commands perform, and that I may want to describe the objects they return in more detail, I think it makes more sense to expose these as resources under kubectl get and describe. That also makes it easier to suggest options:

$ kubectl get
usage: This command expects a resource type and an optional name of a resource to locate.  Use `kubectl get apiresources` to see all valid resource types.

smarterclayton avatar Nov 08 '17 02:11 smarterclayton

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Mar 05 '18 09:03 fejta-bot

/remove-lifecycle stale

nikhita avatar Mar 05 '18 09:03 nikhita

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Jun 03 '18 10:06 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten /remove-lifecycle stale

fejta-bot avatar Jul 03 '18 11:07 fejta-bot

/lifecycle frozen

nikhita avatar Jul 03 '18 11:07 nikhita

/kind feature /area kubectl /priority P2

seans3 avatar Sep 25 '18 21:09 seans3

/assign

soltysh avatar Jul 23 '20 11:07 soltysh

We should go through this and take inventory.

@soltysh will look at.

eddiezane avatar Apr 28 '21 16:04 eddiezane