From 178b5f76381fe532dc024e006f6d786582fa662e Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Mon, 16 May 2016 16:50:13 -0700 Subject: [PATCH] address comments --- docs/man/man1/kubectl-cluster-info-dump.1 | 25 +++++++++++++++++++ docs/man/man1/kubectl-cluster-info.1 | 1 + .../kubectl/kubectl_cluster-info.md | 3 ++- .../kubectl/kubectl_cluster-info_dump.md | 21 +++++++++++++++- docs/yaml/kubectl/kubectl_cluster-info.yaml | 3 ++- pkg/kubectl/cmd/clusterinfo_dump.go | 23 +++++++++-------- pkg/kubectl/cmd/clusterinfo_dump_test.go | 8 +++--- 7 files changed, 66 insertions(+), 18 deletions(-) diff --git a/docs/man/man1/kubectl-cluster-info-dump.1 b/docs/man/man1/kubectl-cluster-info-dump.1 index 208b672aa8d..9d4111da139 100644 --- a/docs/man/man1/kubectl-cluster-info-dump.1 +++ b/docs/man/man1/kubectl-cluster-info-dump.1 @@ -18,6 +18,10 @@ stdout. You can optionally specify a directory with \-\-output\-directory. If y build a set of files in that directory. By default only dumps things in the 'kube\-system' namespace, but you can switch to a different namespace with the \-\-namespaces flag, or specify \-\-all\-namespaces to dump all namespaces. +.PP +The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories +based on namespace and pod name. + .SH OPTIONS .PP @@ -131,6 +135,27 @@ switch to a different namespace with the \-\-namespaces flag, or specify \-\-all comma\-separated list of pattern=N settings for file\-filtered logging +.SH EXAMPLE +.PP +.RS + +.nf +# Dump current cluster state to stdout +kubectl cluster\-info dump + +# Dump current cluster state to /path/to/cluster\-state +kubectl cluster\-info dump \-\-output\-directory=/path/to/cluster\-state + +# Dump all namespaces to stdout +kubectl cluster\-info dump \-\-all\-namespaces + +# Dump a set of namespaces to /path/to/cluster\-state +kubectl cluster\-info dump \-\-namespaces default,kube\-system \-\-output\-directory=/path/to/cluster\-state + +.fi +.RE + + .SH SEE ALSO .PP \fBkubectl\-cluster\-info(1)\fP, diff --git a/docs/man/man1/kubectl-cluster-info.1 b/docs/man/man1/kubectl-cluster-info.1 index 459594a3366..a67f5209b01 100644 --- a/docs/man/man1/kubectl-cluster-info.1 +++ b/docs/man/man1/kubectl-cluster-info.1 @@ -14,6 +14,7 @@ kubectl cluster\-info \- Display cluster info .SH DESCRIPTION .PP Display addresses of the master and services with label kubernetes.io/cluster\-service=true +To further debug and diagnose cluster problems, use 'kubectl cluster\-info dump'. .SH OPTIONS diff --git a/docs/user-guide/kubectl/kubectl_cluster-info.md b/docs/user-guide/kubectl/kubectl_cluster-info.md index e65ab21a3bb..6cc2c282412 100644 --- a/docs/user-guide/kubectl/kubectl_cluster-info.md +++ b/docs/user-guide/kubectl/kubectl_cluster-info.md @@ -40,6 +40,7 @@ Display cluster info Display addresses of the master and services with label kubernetes.io/cluster-service=true +To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. ``` kubectl cluster-info @@ -84,7 +85,7 @@ kubectl cluster-info * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl cluster-info dump](kubectl_cluster-info_dump.md) - Dump lots of relevant info for debugging and diagnosis. -###### Auto generated by spf13/cobra on 27-Apr-2016 +###### Auto generated by spf13/cobra on 16-May-2016 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_cluster-info_dump.md b/docs/user-guide/kubectl/kubectl_cluster-info_dump.md index 1fa6fbb550f..a946b835f20 100644 --- a/docs/user-guide/kubectl/kubectl_cluster-info_dump.md +++ b/docs/user-guide/kubectl/kubectl_cluster-info_dump.md @@ -40,11 +40,30 @@ stdout. You can optionally specify a directory with --output-directory. If you build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces. +The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories +based on namespace and pod name. + ``` kubectl cluster-info dump ``` +### Examples + +``` +# Dump current cluster state to stdout +kubectl cluster-info dump + +# Dump current cluster state to /path/to/cluster-state +kubectl cluster-info dump --output-directory=/path/to/cluster-state + +# Dump all namespaces to stdout +kubectl cluster-info dump --all-namespaces + +# Dump a set of namespaces to /path/to/cluster-state +kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state +``` + ### Options ``` @@ -85,7 +104,7 @@ kubectl cluster-info dump * [kubectl cluster-info](kubectl_cluster-info.md) - Display cluster info -###### Auto generated by spf13/cobra on 27-Apr-2016 +###### Auto generated by spf13/cobra on 16-May-2016 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info_dump.md?pixel)]() diff --git a/docs/yaml/kubectl/kubectl_cluster-info.yaml b/docs/yaml/kubectl/kubectl_cluster-info.yaml index 44ad329311a..bc017e4cfd1 100644 --- a/docs/yaml/kubectl/kubectl_cluster-info.yaml +++ b/docs/yaml/kubectl/kubectl_cluster-info.yaml @@ -1,7 +1,8 @@ name: cluster-info synopsis: Display cluster info -description: | +description: |- Display addresses of the master and services with label kubernetes.io/cluster-service=true + To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. options: - name: include-extended-apis default_value: "true" diff --git a/pkg/kubectl/cmd/clusterinfo_dump.go b/pkg/kubectl/cmd/clusterinfo_dump.go index e40d287ad1f..9a1865902a7 100644 --- a/pkg/kubectl/cmd/clusterinfo_dump.go +++ b/pkg/kubectl/cmd/clusterinfo_dump.go @@ -33,9 +33,10 @@ import ( // NewCmdCreateSecret groups subcommands to create various types of secrets func NewCmdClusterInfoDump(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command { cmd := &cobra.Command{ - Use: "dump", - Short: "Dump lots of relevant info for debugging and diagnosis.", - Long: dumpLong + "\n" + dumpExample, + Use: "dump", + Short: "Dump lots of relevant info for debugging and diagnosis.", + Long: dumpLong, + Example: dumpExample, Run: func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(dumpClusterInfo(f, cmd, args, cmdOut)) }, @@ -57,17 +58,17 @@ The command also dumps the logs of all of the pods in the cluster, these logs ar based on namespace and pod name. ` - dumpExample = ` # Dump current cluster state to stdout - kubectl cluster-info dump + dumpExample = `# Dump current cluster state to stdout +kubectl cluster-info dump - # Dump current cluster state to /path/to/cluster-state - kubectl cluster-info dump --output-directory=/path/to/cluster-state +# Dump current cluster state to /path/to/cluster-state +kubectl cluster-info dump --output-directory=/path/to/cluster-state - # Dump all namespaces to stdout - kubectl cluster-info dump --all-namespaces +# Dump all namespaces to stdout +kubectl cluster-info dump --all-namespaces - # Dump a set of namespaces to /path/to/cluster-state - kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state` +# Dump a set of namespaces to /path/to/cluster-state +kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state` ) func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename string) io.Writer { diff --git a/pkg/kubectl/cmd/clusterinfo_dump_test.go b/pkg/kubectl/cmd/clusterinfo_dump_test.go index 9467e5f96ef..35314525895 100644 --- a/pkg/kubectl/cmd/clusterinfo_dump_test.go +++ b/pkg/kubectl/cmd/clusterinfo_dump_test.go @@ -24,21 +24,21 @@ import ( "testing" ) -func TestGetWriterNoOp(t *testing.T) { +func TestSetupOutputWriterNoOp(t *testing.T) { tests := []string{"", "-"} for _, test := range tests { out := &bytes.Buffer{} f, _, _ := NewAPIFactory() cmd := NewCmdClusterInfoDump(f, os.Stdout) cmd.Flag("output-directory").Value.Set(test) - writer := getWriter(cmd, out, "/some/file/that/should/be/ignored") + writer := setupOutputWriter(cmd, out, "/some/file/that/should/be/ignored") if writer != out { t.Errorf("expected: %v, saw: %v", out, writer) } } } -func TestGetWriterFile(t *testing.T) { +func TestSetupOutputWriterFile(t *testing.T) { file := "output.json" dir, err := ioutil.TempDir(os.TempDir(), "out") if err != nil { @@ -51,7 +51,7 @@ func TestGetWriterFile(t *testing.T) { f, _, _ := NewAPIFactory() cmd := NewCmdClusterInfoDump(f, os.Stdout) cmd.Flag("output-directory").Value.Set(dir) - writer := getWriter(cmd, out, file) + writer := setupOutputWriter(cmd, out, file) if writer == out { t.Errorf("expected: %v, saw: %v", out, writer) }