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

Add a 'kubectl clusterinfo dump' option #20672

Merged
merged 4 commits into from
May 24, 2016

Conversation

brendandburns
Copy link
Contributor

@brendandburns brendandburns commented Feb 4, 2016

Ref: #3500

@bgrant0607 @smarterclayton @jszczepkowski

Usage:

  # Dump current cluster state to stdout
  kubectl clusterinfo dump

  # Dump current cluster state to /tmp
  kubectl clusterinfo dump --output-directory=/tmp

  # Dump all namespaces to stdout
  kubectl clusterinfo dump --all-namespaces

  # Dump a set of namespaces to /tmp
  kubectl clusterinfo dump --namespaces default,kube-system --output-directory=/tmp

This change is Reviewable

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 4, 2016
@smarterclayton
Copy link
Contributor

Is this mostly just an alias for kubectl get pods,nodes,rc,events -o yaml > file?

@brendandburns
Copy link
Contributor Author

@smarterclayton more importantly (imho) it dumps the logs for each pod.

You definitely could do this in bash, but it seems less useful.

--brendan

@smarterclayton
Copy link
Contributor

Ok - yeah, I don't have an issue with a mustgather style command.

@bgrant0607
Copy link
Member

cc @kubernetes/kubectl @dchen1107

},
}
cmd.Flags().String("output-directory", "", "Where to output the files. If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory")
cmd.Flags().StringSlice("namespaces", []string{api.NamespaceSystem}, "A comma separated list of namespaces to dump.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumping the system namespace by default makes sense, but differs from all other kubectl commands, where the current context provides the default namespace.

How about making the default kube-system plus the namespace from the current context?

@bgrant0607
Copy link
Member

I guess this assumes the master kubelet is registered, so we can collect control-plane logs.

Is there a way to get Kubelet logs?

@smarterclayton
Copy link
Contributor

The node proxy can be used to grab them, if they're enabled.

@bgrant0607
Copy link
Member

@brendandburns Are you planning to finish this for 1.2?

cc @dchen1107

@bgrant0607
Copy link
Member

BTW, cluster-info has a dash in it.

@brendandburns
Copy link
Contributor Author

Yes, I'm on finishing this for 1.2 (perhaps not the kubelet logs in this PR, tho)

@brendandburns
Copy link
Contributor Author

PR updated, please take another look.

Thanks!
--brendan

@brendandburns
Copy link
Contributor Author

@bgrant0607 friendly ping on this one...

@bgrant0607
Copy link
Member

Please run hack/update-generated-docs.sh

@bgrant0607 bgrant0607 added this to the v1.2 milestone Mar 5, 2016
@bgrant0607
Copy link
Member

Ok. We can add more resources later, as necessary.

How about a test? Otherwise, this is likely to bitrot.

We're not starting to cherrypick yet. Added v1.2 milestone and cherrypick-candidate label.

@bgrant0607 bgrant0607 assigned j3ffml and unassigned bgrant0607 Mar 6, 2016
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2016
@bgrant0607
Copy link
Member

No activity. Removing from 1.2.

@bgrant0607 bgrant0607 removed this from the v1.2 milestone Mar 15, 2016
@brendandburns
Copy link
Contributor Author

@janetkuo friendly ping on this one.

Thanks!

@@ -43,6 +43,7 @@ func NewCmdClusterInfo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
},
}
cmdutil.AddInclude3rdPartyFlags(cmd)
cmd.AddCommand(NewCmdClusterInfoDump(f, out))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest removing clusterinfo (L37 & L51) since it's deprecated more than 1 year ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a hint of dump when printing results of kubectl cluster-info. Most parent commands will print help message with supported sub-commands, but kubectl cluster-info doesn't do that. WDYT?

Something like,

$ kubectl cluster-info
Kubernetes master is running at http://xxx
...
To further debug and diagnose cluster problems, use `kubectl cluster-info dump`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather remove clusterinfo in a different PR

I added that note.

@janetkuo
Copy link
Member

janetkuo commented May 9, 2016

more importantly (imho) it dumps the logs for each pod.

This should be mentioned in the help (in short/long description and/or examples).

@brendandburns
Copy link
Contributor Author

Comments addressed, please take another look.

--brendan

cmd := &cobra.Command{
Use: "dump",
Short: "Dump lots of relevant info for debugging and diagnosis.",
Long: dumpLong + "\n" + dumpExample,
Copy link
Member

@janetkuo janetkuo May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add the example with Command.Example:

Example: dumpExample,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@janetkuo
Copy link
Member

A few nits; otherwise LGTM.

You'll need to run hack/update-generated-docs.sh also

@brendandburns
Copy link
Contributor Author

Comments addressed, docs generated. ptal.

thanks!
--brendan

@bgrant0607
Copy link
Member

@brendandburns Tests failed

@brendandburns
Copy link
Contributor Author

Test fixed. ptal.

@janetkuo
Copy link
Member

LGTM. Squash and feel free to apply the tag.

@brendandburns brendandburns added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 23, 2016
@k8s-bot
Copy link

k8s-bot commented May 23, 2016

GCE e2e build/test passed for commit 178b5f7.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented May 24, 2016

GCE e2e build/test passed for commit 178b5f7.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 50524c7 into kubernetes:master May 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants