{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/51973206","id":51973206,"diff_hunk":"@@ -0,0 +1,168 @@\n+/*\n+Copyright 2016 The Kubernetes Authors All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package cmd\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\t\"os\"\n+\t\"path\"\n+\n+\t\"github.com/spf13/cobra\"\n+\n+\t\"k8s.io/kubernetes/pkg/api\"\n+\t\"k8s.io/kubernetes/pkg/client/unversioned\"\n+\t\"k8s.io/kubernetes/pkg/kubectl\"\n+\tcmdutil \"k8s.io/kubernetes/pkg/kubectl/cmd/util\"\n+)\n+\n+// NewCmdCreateSecret groups subcommands to create various types of secrets\n+func NewCmdClusterInfoDump(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Command {\n+\tcmd := &cobra.Command{\n+\t\tUse:   \"dump\",\n+\t\tShort: \"Dump lots of relevant info for debugging and diagnosis.\",\n+\t\tLong:  dumpLong,\n+\t\tRun: func(cmd *cobra.Command, args []string) {\n+\t\t\tcmdutil.CheckErr(dumpClusterInfo(f, cmd, args, cmdOut))\n+\t\t},\n+\t}\n+\tcmd.Flags().String(\"output-directory\", \"\", \"Where to output the files.  If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory\")\n+\tcmd.Flags().StringSlice(\"namespaces\", []string{api.NamespaceSystem}, \"A comma separated list of namespaces to dump.\")\n+\tcmd.Flags().Bool(\"all-namespaces\", false, \"If true, dump all namespaces.  If true, --namespaces is ignored.\")\n+\treturn cmd\n+}\n+\n+const (\n+\tdumpLong = `\n+Dumps cluster info out suitable for debugging and diagnosing cluster problems.  By default, dumps everything to\n+stdout. You can optionally specify a directory with --output-directory.  If you specify a directory, kubernetes will\n+build a set of files in that directory.  By default only dumps things in the 'kube-system' namespace, but you can\n+switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.\n+`\n+\n+\tdumpExample = `  # Dump current cluster state to stdout\n+  kubectl clusterinfo dump\n+  \n+  # Dump current cluster state to /tmp\n+  kubectl clusterinfo dump --output-directory=/tmp\n+  \n+  # Dump all namespaces to stdout\n+  kubectl clusterinfo dump --all-namespaces\n+  \n+  # Dump a set of namespaces to /tmp\n+  kubectl clusterinfo dump --namespaces default,kube-system --output-directory=/tmp`\n+)\n+\n+func getWriter(cmd *cobra.Command, out io.Writer, filename string) io.Writer {\n+\tdir := cmdutil.GetFlagString(cmd, \"output-directory\")\n+\tif len(dir) == 0 || dir == \"-\" {\n+\t\treturn out\n+\t}\n+\tfullFile := path.Join(dir, filename)\n+\tparent := path.Dir(fullFile)\n+\tcmdutil.CheckErr(os.MkdirAll(parent, 0755))\n+\n+\tfile, err := os.Create(path.Join(dir, filename))\n+\tcmdutil.CheckErr(err)\n+\treturn file\n+}\n+\n+func dumpClusterInfo(f *cmdutil.Factory, cmd *cobra.Command, args []string, out io.Writer) error {\n+\tvar c *unversioned.Client\n+\tvar err error\n+\tif c, err = f.Client(); err != nil {\n+\t\treturn err\n+\t}\n+\tprinter, _, err := kubectl.GetPrinter(\"json\", \"\")\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tnodes, err := c.Nodes().List(api.ListOptions{})\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tif err := printer.PrintObj(nodes, getWriter(cmd, out, \"nodes.json\")); err != nil {\n+\t\treturn err\n+\t}\n+\n+\tvar namespaces []string\n+\tif cmdutil.GetFlagBool(cmd, \"all-namespaces\") {\n+\t\tnamespaceList, err := c.Namespaces().List(api.ListOptions{})\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tfor ix := range namespaceList.Items {\n+\t\t\tnamespaces = append(namespaces, namespaceList.Items[ix].Name)\n+\t\t}\n+\t} else {\n+\t\tnamespaces = cmdutil.GetFlagStringSlice(cmd, \"namespaces\")\n+\t}\n+\tfor _, namespace := range namespaces {\n+\t\tevents, err := c.Events(namespace).List(api.ListOptions{})\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tif err := printer.PrintObj(events, getWriter(cmd, out, path.Join(namespace, \"events.json\"))); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\trcs, err := c.ReplicationControllers(namespace).List(api.ListOptions{})","path":"pkg/kubectl/cmd/clusterinfo_dump.go","position":125,"original_position":125,"commit_id":"b1df4eef417b741bfc0cecb7aa6e69412928b830","original_commit_id":"b1df4eef417b741bfc0cecb7aa6e69412928b830","user":{"login":"bgrant0607","id":7725777,"avatar_url":"https://avatars.githubusercontent.com/u/7725777?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrant0607","html_url":"https://github.com/bgrant0607","followers_url":"https://api.github.com/users/bgrant0607/followers","following_url":"https://api.github.com/users/bgrant0607/following{/other_user}","gists_url":"https://api.github.com/users/bgrant0607/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrant0607/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrant0607/subscriptions","organizations_url":"https://api.github.com/users/bgrant0607/orgs","repos_url":"https://api.github.com/users/bgrant0607/repos","events_url":"https://api.github.com/users/bgrant0607/events{/privacy}","received_events_url":"https://api.github.com/users/bgrant0607/received_events","type":"User","site_admin":false},"body":"How often are the controllers important? We're adding lots of new controllers...","created_at":"2016-02-05T03:23:59Z","updated_at":"2016-02-05T03:23:59Z","html_url":"https://github.com/kubernetes/kubernetes/pull/20672#discussion_r51973206","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/51973206"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/20672#discussion_r51973206"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672","id":58357940,"html_url":"https://github.com/kubernetes/kubernetes/pull/20672","diff_url":"https://github.com/kubernetes/kubernetes/pull/20672.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/20672.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/20672","number":20672,"state":"open","locked":false,"title":"Add a 'kubectl clusterinfo dump' option","user":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"body":"Ref: #3500 \r\n\r\n@bgrant0607 @smarterclayton @jszczepkowski \r\n\r\nUsage:\r\n```\r\n  # Dump current cluster state to stdout\r\n  kubectl clusterinfo dump\r\n  \r\n  # Dump current cluster state to /tmp\r\n  kubectl clusterinfo dump --output-directory=/tmp\r\n  \r\n  # Dump all namespaces to stdout\r\n  kubectl clusterinfo dump --all-namespaces\r\n  \r\n  # Dump a set of namespaces to /tmp\r\n  kubectl clusterinfo dump --namespaces default,kube-system --output-directory=/tmp\r\n```","created_at":"2016-02-04T22:14:58Z","updated_at":"2016-02-05T03:23:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2ded2f74d42aa8ba632b3f2f8fe1edc43a94503","assignee":{"login":"bgrant0607","id":7725777,"avatar_url":"https://avatars.githubusercontent.com/u/7725777?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrant0607","html_url":"https://github.com/bgrant0607","followers_url":"https://api.github.com/users/bgrant0607/followers","following_url":"https://api.github.com/users/bgrant0607/following{/other_user}","gists_url":"https://api.github.com/users/bgrant0607/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrant0607/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrant0607/subscriptions","organizations_url":"https://api.github.com/users/bgrant0607/orgs","repos_url":"https://api.github.com/users/bgrant0607/repos","events_url":"https://api.github.com/users/bgrant0607/events{/privacy}","received_events_url":"https://api.github.com/users/bgrant0607/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/20672/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/b1df4eef417b741bfc0cecb7aa6e69412928b830","head":{"label":"brendandburns:dump","ref":"dump","sha":"b1df4eef417b741bfc0cecb7aa6e69412928b830","user":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"repo":{"id":20748715,"name":"kubernetes","full_name":"brendandburns/kubernetes","owner":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brendandburns/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/brendandburns/kubernetes","forks_url":"https://api.github.com/repos/brendandburns/kubernetes/forks","keys_url":"https://api.github.com/repos/brendandburns/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brendandburns/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brendandburns/kubernetes/teams","hooks_url":"https://api.github.com/repos/brendandburns/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/brendandburns/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/brendandburns/kubernetes/events","assignees_url":"https://api.github.com/repos/brendandburns/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/brendandburns/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/brendandburns/kubernetes/tags","blobs_url":"https://api.github.com/repos/brendandburns/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brendandburns/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brendandburns/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/brendandburns/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brendandburns/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/brendandburns/kubernetes/languages","stargazers_url":"https://api.github.com/repos/brendandburns/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/brendandburns/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/brendandburns/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/brendandburns/kubernetes/subscription","commits_url":"https://api.github.com/repos/brendandburns/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/brendandburns/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/brendandburns/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/brendandburns/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/brendandburns/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/brendandburns/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brendandburns/kubernetes/merges","archive_url":"https://api.github.com/repos/brendandburns/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brendandburns/kubernetes/downloads","issues_url":"https://api.github.com/repos/brendandburns/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/brendandburns/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/brendandburns/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/brendandburns/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brendandburns/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/brendandburns/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/brendandburns/kubernetes/deployments","created_at":"2014-06-12T00:13:18Z","updated_at":"2015-11-04T01:16:02Z","pushed_at":"2016-02-04T22:14:45Z","git_url":"git://github.com/brendandburns/kubernetes.git","ssh_url":"git@github.com:brendandburns/kubernetes.git","clone_url":"https://github.com/brendandburns/kubernetes.git","svn_url":"https://github.com/brendandburns/kubernetes","homepage":null,"size":161334,"stargazers_count":11,"watchers_count":11,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":11,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"ad9fa30e7e3d578a20dc5a49828dc2ac111ea5dd","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/kubernetes/deployments","created_at":"2014-06-06T22:56:04Z","updated_at":"2016-02-05T01:54:17Z","pushed_at":"2016-02-05T03:17:29Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":318163,"stargazers_count":12516,"watchers_count":12516,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3556,"mirror_url":null,"open_issues_count":2850,"forks":3556,"open_issues":2850,"watchers":12516,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/20672"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/20672"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/20672/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/20672/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/b1df4eef417b741bfc0cecb7aa6e69412928b830"}}}}