Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed May 17, 2016
1 parent d8daa07 commit 178b5f7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
25 changes: 25 additions & 0 deletions docs/man/man1/kubectl-cluster-info-dump.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions docs/man/man1/kubectl-cluster-info.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/user-guide/kubectl/kubectl_cluster-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info.md?pixel)]()
Expand Down
21 changes: 20 additions & 1 deletion docs/user-guide/kubectl/kubectl_cluster-info_dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,28 @@ 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
Expand Down Expand Up @@ -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

<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info_dump.md?pixel)]()
Expand Down
3 changes: 2 additions & 1 deletion docs/yaml/kubectl/kubectl_cluster-info.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
23 changes: 12 additions & 11 deletions pkg/kubectl/cmd/clusterinfo_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
},
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/clusterinfo_dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit 178b5f7

Please sign in to comment.