Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a real "get-all" command #527

Closed
schollii opened this issue Aug 29, 2018 · 29 comments
Closed

Need a real "get-all" command #527

schollii opened this issue Aug 29, 2018 · 29 comments
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@schollii
Copy link

schollii commented Aug 29, 2018

FEATURE REQUEST:

Add a get-all command that really shows all objects, with some flags to filter on certain types (namespaced vs non-namespaced, etc).

Similarly, the dashboard should have a mode to show all resources (again, dashboard does not show networkpolicy objects, not even in pod descriptions to say "this pod is selected by this networkpolicy object". But dashboard improvement should be implemented separately, as the most important and urgent one is the kubectl new command.

Kubernetes version (use kubectl version):

1.11.2

What happened:

kubectl get all only shows a small subset of kubernetes objects in a cluster, and there does not seem to be a command to get all objects (secrets, network policies, etc). This caused me hours of wasted time because I was trying to replicate a deployment object from another cluster into a new cluster, and didn't see that there was a networkpolicy needed for the service to expose that deployment.

What you expected to happen:

That kubect get all would show all, not just a small number of types of resources.

How to reproduce it (as minimally and precisely as possible):

Create a networkpolicy then do kubectl get all, it doesn't show up. However, it does show up with kubectl get netpol and kubectl api-resources -o name | xargs -t -n 1 kubectl get --ignore-not-found --show-kind | grep SOMETHING_IN_NAME

@seans3
Copy link
Contributor

seans3 commented Sep 26, 2018

/kind feature
/sig cli
/area kubectl
/priority P3

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI. area/kubectl priority/P3 labels Sep 26, 2018
@juanvallejo
Copy link

This functionality sounds like something that'd be great to implement as a plugin

@schollii
Copy link
Author

Where would I start? I know some Go and I have lots of software dev experience so that part is not a problem, it's more the logistics : how do I mark that I'm working on this so people know, where do I publish it for peer review, for downloading, etc. I found https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/, are there other links that I should look at?

@juanvallejo
Copy link

juanvallejo commented Sep 27, 2018

@schollii

Where would I start?

I am currently updating the docs for plugins, so that they are up to date with the current plugin system: kubernetes/website#10259, see https://deploy-preview-10259--kubernetes-io-master-staging.netlify.com/docs/tasks/extend-kubectl/kubectl-plugins/ (while that PR merges) for an accurate doc on the current state of plugins.

You can also take a look at https://github.com/kubernetes/sample-cli-plugin for a detailed example of writing a plugin in Go.

how do I mark that I'm working on this so people know, where do I publish it for peer review, for downloading, etc

Although there's no official registry or repo where you would formally declare your work on a plugin (for now), you are always welcome to host it on a repo of your own, and link to it in the slack channel for SIG-CLI, as well as request peer review there.

I'd be happy to help review it as well. Feel free to reach out on Slack with any questions.
Thanks

@juanvallejo
Copy link

@schollii plugin documentation has now been updated. You can find a guide for writing plugins under the new mechanism at: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/#writing-kubectl-plugins

@seans3 seans3 added this to Low priority in kubectl prioritized bugs Oct 5, 2018
@seans3 seans3 moved this from Low priority (P2/P3) to Priority P3 in kubectl prioritized bugs Oct 5, 2018
@seans3 seans3 removed this from Priority P3 in kubectl prioritized bugs Nov 9, 2018
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 27, 2018
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 26, 2019
@schollii
Copy link
Author

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 26, 2019
@corneliusweig
Copy link
Contributor

@schollii Have a look at https://github.com/corneliusweig/ketall . It is also available via krew, so that it can be installed via kubectl krew install get-all. Please raise an issue, if this doesn't fully meet your requirements.

@rohantmp
Copy link

rohantmp commented Mar 7, 2019

quick hack: kubectl get $(kubectl api-resources| awk '{ print $1 }'|grep -v "NAME"|xargs|sed -e 's/ /,/g')

@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 5, 2019
@alexkreidler
Copy link

I firmly believe that this functionality belongs in the core. It is unrealistic to say that you are displaying all kubernetes resources and it is misleading.

@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 28, 2019
@towolf
Copy link

towolf commented Jul 29, 2019

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 29, 2019
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 27, 2019
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 26, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

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/test-infra repository.

@foobarbecue
Copy link

foobarbecue commented May 15, 2020

/reopen

@foobarbecue
Copy link

foobarbecue commented May 15, 2020

This one of the the weirdest, most confusing things about learning k8s; the fact that "get all" means "get a few random things" . If "all" doesn't mean "all," rename it "common" or "basic" something.

@nsvijay04b1
Copy link

please /reopen

@bendavis78
Copy link

Note that you can pass a comma-separated list of resource kinds to the get command:

$ kubectl get deployments,services,ingresses -l app=myapp

You can use the following command (no xargs required) to get literally all resource types:

$ kubectl get $(kubectl api-resources --verbs=list --namespaced -o name | paste -sd ',') -l app=myapp

@schollii
Copy link
Author

schollii commented Aug 3, 2020

@bendavis78 nice but I don't want to have to type that every time, nor create an alias for this on every system where I use kubectl. kubectl get all -l app=myapp should do the go-equivalent of your solution.

Given the API already exists, the change should be simple. I don't mind doing it I just need a go-ahead, and a little guidance. The api-resources command can likely be called via

func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Factory) error {
. For the get command, looks like I would edit https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/get/get.go. In particular, somewhere in the vicinity of
r := f.NewBuilder().
I would do the following:

  • call RunAPIResources() on a APIResourceOptions that equates to --verbs=list --namespaced -o name
  • loop over the types received; for each one, call the Run() of GetOptions with the same options as given to the get command, but minus the all type
  • aggregate the output and then print it (probably use the --all-namespaces as guidance since it probably does basically the same logic just for namespaces instead of resource types)

Am I getting this right?

@eddiezane
Copy link
Member

I'm not sure the historical context on this one but we can reopen until we get an official word out.

/remove-lifecycle rotten
/remove-priority P3
/triage needs-information
/reopen

@k8s-ci-robot k8s-ci-robot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed priority/P3 labels Aug 3, 2020
@k8s-ci-robot k8s-ci-robot reopened this Aug 3, 2020
@k8s-ci-robot
Copy link
Contributor

@eddiezane: Reopened this issue.

In response to this:

I'm not sure the historical context on this one but we can reopen until we get an official word out.

/remove-lifecycle rotten
/remove-priority P3
/triage needs-information
/reopen

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Aug 3, 2020
@eddiezane
Copy link
Member

Following up..

kubectl get all is a legacy command and is actually implemented with a hardcoded server side list that is not easy to maintain. There is potential that it will be removed in the future and therefore will not be expanded upon or improved at this time.

We recommend using ketall which can be installed standalone or via krew.

/close

@k8s-ci-robot
Copy link
Contributor

@eddiezane: Closing this issue.

In response to this:

Following up..

kubectl get all is a legacy command and is actually implemented with a hardcoded server side list that is not easy to maintain. There is potential that it will be removed in the future and therefore will not be expanded upon or improved at this time.

We recommend using ketall which can be installed standalone or via krew.

/close

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/test-infra repository.

@foobarbecue
Copy link

foobarbecue commented Aug 18, 2020

Wow. You have to install extra stuff to do something this basic? Bizarre. If the existing command is poorly implemented, and doesn't provide the results people expect, why can't it be re-implemented correctly?

@schollii
Copy link
Author

I was going to ask exactly that. I've outlined a solution, plus we could adapt code from ketall.

/reopen please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests