diff --git a/.generated_docs b/.generated_docs
index a337375038d..96dd0f02f85 100644
--- a/.generated_docs
+++ b/.generated_docs
@@ -13,6 +13,7 @@ docs/man/man1/kubectl-config-unset.1
docs/man/man1/kubectl-config-use-context.1
docs/man/man1/kubectl-config-view.1
docs/man/man1/kubectl-config.1
+docs/man/man1/kubectl-convert.1
docs/man/man1/kubectl-create.1
docs/man/man1/kubectl-delete.1
docs/man/man1/kubectl-describe.1
@@ -48,6 +49,7 @@ docs/user-guide/kubectl/kubectl_config_set.md
docs/user-guide/kubectl/kubectl_config_unset.md
docs/user-guide/kubectl/kubectl_config_use-context.md
docs/user-guide/kubectl/kubectl_config_view.md
+docs/user-guide/kubectl/kubectl_convert.md
docs/user-guide/kubectl/kubectl_create.md
docs/user-guide/kubectl/kubectl_delete.md
docs/user-guide/kubectl/kubectl_describe.md
diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl
index 157aa75ab95..2d707aebcae 100644
--- a/contrib/completions/bash/kubectl
+++ b/contrib/completions/bash/kubectl
@@ -1152,6 +1152,41 @@ _kubectl_explain()
must_have_one_noun=()
}
+_kubectl_convert()
+{
+ last_command="kubectl_convert"
+ commands=()
+
+ flags=()
+ two_word_flags=()
+ flags_with_completion=()
+ flags_completion=()
+
+ flags+=("--filename=")
+ flags_with_completion+=("--filename")
+ flags_completion+=("__handle_filename_extension_flag json|stdin|yaml|yml")
+ two_word_flags+=("-f")
+ flags_with_completion+=("-f")
+ flags_completion+=("__handle_filename_extension_flag json|stdin|yaml|yml")
+ flags+=("--local")
+ flags+=("--no-headers")
+ flags+=("--output=")
+ two_word_flags+=("-o")
+ flags+=("--output-version=")
+ flags+=("--schema-cache-dir=")
+ flags+=("--show-all")
+ flags+=("-a")
+ flags+=("--sort-by=")
+ flags+=("--template=")
+ two_word_flags+=("-t")
+ flags+=("--validate")
+
+ must_have_one_flag=()
+ must_have_one_flag+=("--filename=")
+ must_have_one_flag+=("-f")
+ must_have_one_noun=()
+}
+
_kubectl()
{
last_command="kubectl"
@@ -1182,6 +1217,7 @@ _kubectl()
commands+=("api-versions")
commands+=("version")
commands+=("explain")
+ commands+=("convert")
flags=()
two_word_flags=()
diff --git a/docs/man/man1/.files_generated b/docs/man/man1/.files_generated
index 097fb577aeb..a7620fa8226 100644
--- a/docs/man/man1/.files_generated
+++ b/docs/man/man1/.files_generated
@@ -11,6 +11,7 @@ kubectl-config-unset.1
kubectl-config-use-context.1
kubectl-config-view.1
kubectl-config.1
+kubectl-convert.1
kubectl-create.1
kubectl-delete.1
kubectl-describe.1
diff --git a/docs/man/man1/kubectl-convert.1 b/docs/man/man1/kubectl-convert.1
new file mode 100644
index 00000000000..9c806b079dc
--- /dev/null
+++ b/docs/man/man1/kubectl-convert.1
@@ -0,0 +1,195 @@
+.TH "KUBERNETES" "1" " kubernetes User Manuals" "Eric Paris" "Jan 2015" ""
+
+
+.SH NAME
+.PP
+kubectl convert \- Convert config files between different API versions
+
+
+.SH SYNOPSIS
+.PP
+\fBkubectl convert\fP [OPTIONS]
+
+
+.SH DESCRIPTION
+.PP
+Convert config files between different API versions. Both YAML
+and JSON formats are accepted.
+
+.PP
+The command takes filename, directory, or URL as input, and convert it into format
+of version specified by \-\-output\-version flag. If target version is not specified or
+not supported, convert to latest version.
+
+.PP
+The default output will be printed to stdout in YAML format. One can use \-o option
+to change to output destination.
+
+
+.SH OPTIONS
+.PP
+\fB\-f\fP, \fB\-\-filename\fP=[]
+ Filename, directory, or URL to file to need to get converted.
+
+.PP
+\fB\-\-local\fP=true
+ If true, convert will NOT try to contact api\-server but run locally.
+
+.PP
+\fB\-\-no\-headers\fP=false
+ When using the default output, don't print headers.
+
+.PP
+\fB\-o\fP, \fB\-\-output\fP=""
+ Output format. One of: json|yaml|wide|name|go\-template=...|go\-template\-file=...|jsonpath=...|jsonpath\-file=... See golang template [
+\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]] and jsonpath template [
+\[la]http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md\[ra]].
+
+.PP
+\fB\-\-output\-version\fP=""
+ Output the formatted object with the given version (default api\-version).
+
+.PP
+\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
+ If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
+
+.PP
+\fB\-a\fP, \fB\-\-show\-all\fP=false
+ When printing, show all resources (default hide terminated pods.)
+
+.PP
+\fB\-\-sort\-by\fP=""
+ If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
+
+.PP
+\fB\-t\fP, \fB\-\-template\fP=""
+ Template string or path to template file to use when \-o=go\-template, \-o=go\-template\-file. The template format is golang templates [
+\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]].
+
+.PP
+\fB\-\-validate\fP=true
+ If true, use a schema to validate the input before sending it
+
+
+.SH OPTIONS INHERITED FROM PARENT COMMANDS
+.PP
+\fB\-\-alsologtostderr\fP=false
+ log to standard error as well as files
+
+.PP
+\fB\-\-api\-version\fP=""
+ The API version to use when talking to the server
+
+.PP
+\fB\-\-certificate\-authority\fP=""
+ Path to a cert. file for the certificate authority.
+
+.PP
+\fB\-\-client\-certificate\fP=""
+ Path to a client key file for TLS.
+
+.PP
+\fB\-\-client\-key\fP=""
+ Path to a client key file for TLS.
+
+.PP
+\fB\-\-cluster\fP=""
+ The name of the kubeconfig cluster to use
+
+.PP
+\fB\-\-context\fP=""
+ The name of the kubeconfig context to use
+
+.PP
+\fB\-\-insecure\-skip\-tls\-verify\fP=false
+ If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
+
+.PP
+\fB\-\-kubeconfig\fP=""
+ Path to the kubeconfig file to use for CLI requests.
+
+.PP
+\fB\-\-log\-backtrace\-at\fP=:0
+ when logging hits line file:N, emit a stack trace
+
+.PP
+\fB\-\-log\-dir\fP=""
+ If non\-empty, write log files in this directory
+
+.PP
+\fB\-\-log\-flush\-frequency\fP=5s
+ Maximum number of seconds between log flushes
+
+.PP
+\fB\-\-logtostderr\fP=true
+ log to standard error instead of files
+
+.PP
+\fB\-\-match\-server\-version\fP=false
+ Require server version to match client version
+
+.PP
+\fB\-\-namespace\fP=""
+ If present, the namespace scope for this CLI request.
+
+.PP
+\fB\-\-password\fP=""
+ Password for basic authentication to the API server.
+
+.PP
+\fB\-s\fP, \fB\-\-server\fP=""
+ The address and port of the Kubernetes API server
+
+.PP
+\fB\-\-stderrthreshold\fP=2
+ logs at or above this threshold go to stderr
+
+.PP
+\fB\-\-token\fP=""
+ Bearer token for authentication to the API server.
+
+.PP
+\fB\-\-user\fP=""
+ The name of the kubeconfig user to use
+
+.PP
+\fB\-\-username\fP=""
+ Username for basic authentication to the API server.
+
+.PP
+\fB\-\-v\fP=0
+ log level for V logs
+
+.PP
+\fB\-\-vmodule\fP=
+ comma\-separated list of pattern=N settings for file\-filtered logging
+
+
+.SH EXAMPLE
+.PP
+.RS
+
+.nf
+# Convert 'pod.yaml' to latest version and print to stdout.
+$ kubectl convert \-f pod.yaml
+
+# Convert the live state of the resource specified by 'pod.yaml' to the latest version
+# and print to stdout in json format.
+$ kubectl convert \-f pod.yaml \-\-local \-o json
+
+# Convert all files under current directory to latest version and create them all.
+$ kubectl convert \-f . | kubectl create \-f \-
+
+
+.fi
+.RE
+
+
+.SH SEE ALSO
+.PP
+\fBkubectl(1)\fP,
+
+
+.SH HISTORY
+.PP
+January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since!
diff --git a/docs/man/man1/kubectl.1 b/docs/man/man1/kubectl.1
index f71e4b33baa..d4acb7899cb 100644
--- a/docs/man/man1/kubectl.1
+++ b/docs/man/man1/kubectl.1
@@ -116,7 +116,7 @@ Find more information at
.SH SEE ALSO
.PP
-\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-replace(1)\fP, \fBkubectl\-patch(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-edit(1)\fP, \fBkubectl\-apply(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-logs(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-scale(1)\fP, \fBkubectl\-attach(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-annotate(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-explain(1)\fP,
+\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-replace(1)\fP, \fBkubectl\-patch(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-edit(1)\fP, \fBkubectl\-apply(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-logs(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-scale(1)\fP, \fBkubectl\-attach(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-annotate(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-explain(1)\fP, \fBkubectl\-convert(1)\fP,
.SH HISTORY
diff --git a/docs/user-guide/kubectl/.files_generated b/docs/user-guide/kubectl/.files_generated
index a05143cf35d..dc332659711 100644
--- a/docs/user-guide/kubectl/.files_generated
+++ b/docs/user-guide/kubectl/.files_generated
@@ -12,6 +12,7 @@ kubectl_config_set.md
kubectl_config_unset.md
kubectl_config_use-context.md
kubectl_config_view.md
+kubectl_convert.md
kubectl_create.md
kubectl_delete.md
kubectl_describe.md
diff --git a/docs/user-guide/kubectl/kubectl.md b/docs/user-guide/kubectl/kubectl.md
index 4fefaa22d32..78074d249e6 100644
--- a/docs/user-guide/kubectl/kubectl.md
+++ b/docs/user-guide/kubectl/kubectl.md
@@ -82,6 +82,7 @@ kubectl
* [kubectl attach](kubectl_attach.md) - Attach to a running container.
* [kubectl cluster-info](kubectl_cluster-info.md) - Display cluster info
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
+* [kubectl convert](kubectl_convert.md) - Convert config files between different API versions
* [kubectl create](kubectl_create.md) - Create a resource by filename or stdin
* [kubectl delete](kubectl_delete.md) - Delete resources by filenames, stdin, resources and names, or by resources and label selector.
* [kubectl describe](kubectl_describe.md) - Show details of a specific resource or group of resources
@@ -103,7 +104,7 @@ kubectl
* [kubectl stop](kubectl_stop.md) - Deprecated: Gracefully shut down a resource by name or filename.
* [kubectl version](kubectl_version.md) - Print the client and server version information.
-###### Auto generated by spf13/cobra at 2015-09-22 11:13:47.6353025 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_annotate.md b/docs/user-guide/kubectl/kubectl_annotate.md
index a6b7831c3c6..96bf878ebc9 100644
--- a/docs/user-guide/kubectl/kubectl_annotate.md
+++ b/docs/user-guide/kubectl/kubectl_annotate.md
@@ -119,7 +119,7 @@ $ kubectl annotate pods foo description-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.16095949 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293299401 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_api-versions.md b/docs/user-guide/kubectl/kubectl_api-versions.md
index 15051d3f917..73f48d1b5fc 100644
--- a/docs/user-guide/kubectl/kubectl_api-versions.md
+++ b/docs/user-guide/kubectl/kubectl_api-versions.md
@@ -76,7 +76,7 @@ kubectl api-versions
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.164255617 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294634813 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_attach.md b/docs/user-guide/kubectl/kubectl_attach.md
index e4aadda49a1..8596c4795b4 100644
--- a/docs/user-guide/kubectl/kubectl_attach.md
+++ b/docs/user-guide/kubectl/kubectl_attach.md
@@ -98,7 +98,7 @@ $ kubectl attach 123456-7890 -c ruby-container -i -t
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.934629688 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_cluster-info.md b/docs/user-guide/kubectl/kubectl_cluster-info.md
index 465984de41b..a3aeeed884e 100644
--- a/docs/user-guide/kubectl/kubectl_cluster-info.md
+++ b/docs/user-guide/kubectl/kubectl_cluster-info.md
@@ -76,7 +76,7 @@ kubectl cluster-info
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163962347 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294524092 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config.md b/docs/user-guide/kubectl/kubectl_config.md
index b1aa25fb8b9..07d66e5b611 100644
--- a/docs/user-guide/kubectl/kubectl_config.md
+++ b/docs/user-guide/kubectl/kubectl_config.md
@@ -94,7 +94,7 @@ kubectl config SUBCOMMAND
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a kubeconfig file
* [kubectl config view](kubectl_config_view.md) - Displays merged kubeconfig settings or a specified kubeconfig file.
-###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.253683538 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-27 07:12:26.012369724 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_set-cluster.md b/docs/user-guide/kubectl/kubectl_config_set-cluster.md
index 414f7cc08a0..407cbb8aa15 100644
--- a/docs/user-guide/kubectl/kubectl_config_set-cluster.md
+++ b/docs/user-guide/kubectl/kubectl_config_set-cluster.md
@@ -96,7 +96,7 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.161700827 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293649266 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_set-context.md b/docs/user-guide/kubectl/kubectl_config_set-context.md
index 15643a2d8c8..1ab3f43f6f2 100644
--- a/docs/user-guide/kubectl/kubectl_config_set-context.md
+++ b/docs/user-guide/kubectl/kubectl_config_set-context.md
@@ -89,7 +89,7 @@ $ kubectl config set-context gce --user=cluster-admin
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162402642 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293919632 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_set-credentials.md b/docs/user-guide/kubectl/kubectl_config_set-credentials.md
index c4663ae0e34..f3dd56472d6 100644
--- a/docs/user-guide/kubectl/kubectl_config_set-credentials.md
+++ b/docs/user-guide/kubectl/kubectl_config_set-credentials.md
@@ -109,7 +109,7 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162045132 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293801607 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_set.md b/docs/user-guide/kubectl/kubectl_config_set.md
index 9f72013f061..1f73a380bfd 100644
--- a/docs/user-guide/kubectl/kubectl_config_set.md
+++ b/docs/user-guide/kubectl/kubectl_config_set.md
@@ -78,7 +78,7 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162716308 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294028359 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_unset.md b/docs/user-guide/kubectl/kubectl_config_unset.md
index 1f609d34faf..6985f8fec45 100644
--- a/docs/user-guide/kubectl/kubectl_config_unset.md
+++ b/docs/user-guide/kubectl/kubectl_config_unset.md
@@ -77,7 +77,7 @@ kubectl config unset PROPERTY_NAME
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163015642 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294142791 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_use-context.md b/docs/user-guide/kubectl/kubectl_config_use-context.md
index d2dbdc773fb..0d6ac7f3e21 100644
--- a/docs/user-guide/kubectl/kubectl_config_use-context.md
+++ b/docs/user-guide/kubectl/kubectl_config_use-context.md
@@ -76,7 +76,7 @@ kubectl config use-context CONTEXT_NAME
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163336177 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294246651 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_config_view.md b/docs/user-guide/kubectl/kubectl_config_view.md
index 8490d7482a0..fcbbe41b823 100644
--- a/docs/user-guide/kubectl/kubectl_config_view.md
+++ b/docs/user-guide/kubectl/kubectl_config_view.md
@@ -103,7 +103,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
-###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.252744701 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-27 07:12:26.010616625 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_convert.md b/docs/user-guide/kubectl/kubectl_convert.md
new file mode 100644
index 00000000000..6f11738a534
--- /dev/null
+++ b/docs/user-guide/kubectl/kubectl_convert.md
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
PLEASE NOTE: This document applies to the HEAD of the source tree
+
+If you are using a released version of Kubernetes, you should
+refer to the docs that go with that version.
+
+
+The latest 1.0.x release of this document can be found
+[here](http://releases.k8s.io/release-1.0/docs/user-guide/kubectl/kubectl_convert.md).
+
+Documentation for other releases can be found at
+[releases.k8s.io](http://releases.k8s.io).
+
+--
+
+
+
+
+
+## kubectl convert
+
+Convert config files between different API versions
+
+### Synopsis
+
+
+Convert config files between different API versions. Both YAML
+and JSON formats are accepted.
+
+The command takes filename, directory, or URL as input, and convert it into format
+of version specified by --output-version flag. If target version is not specified or
+not supported, convert to latest version.
+
+The default output will be printed to stdout in YAML format. One can use -o option
+to change to output destination.
+
+
+```
+kubectl convert -f FILENAME
+```
+
+### Examples
+
+```
+# Convert 'pod.yaml' to latest version and print to stdout.
+$ kubectl convert -f pod.yaml
+
+# Convert the live state of the resource specified by 'pod.yaml' to the latest version
+# and print to stdout in json format.
+$ kubectl convert -f pod.yaml --local -o json
+
+# Convert all files under current directory to latest version and create them all.
+$ kubectl convert -f . | kubectl create -f -
+
+```
+
+### Options
+
+```
+ -f, --filename=[]: Filename, directory, or URL to file to need to get converted.
+ --local[=true]: If true, convert will NOT try to contact api-server but run locally.
+ --no-headers[=false]: When using the default output, don't print headers.
+ -o, --output="": Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md].
+ --output-version="": Output the formatted object with the given version (default api-version).
+ --schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
+ -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
+ --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
+ --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
+ --validate[=true]: If true, use a schema to validate the input before sending it
+```
+
+### Options inherited from parent commands
+
+```
+ --alsologtostderr[=false]: log to standard error as well as files
+ --api-version="": The API version to use when talking to the server
+ --certificate-authority="": Path to a cert. file for the certificate authority.
+ --client-certificate="": Path to a client key file for TLS.
+ --client-key="": Path to a client key file for TLS.
+ --cluster="": The name of the kubeconfig cluster to use
+ --context="": The name of the kubeconfig context to use
+ --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
+ --kubeconfig="": Path to the kubeconfig file to use for CLI requests.
+ --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
+ --log-dir="": If non-empty, write log files in this directory
+ --log-flush-frequency=5s: Maximum number of seconds between log flushes
+ --logtostderr[=true]: log to standard error instead of files
+ --match-server-version[=false]: Require server version to match client version
+ --namespace="": If present, the namespace scope for this CLI request.
+ --password="": Password for basic authentication to the API server.
+ -s, --server="": The address and port of the Kubernetes API server
+ --stderrthreshold=2: logs at or above this threshold go to stderr
+ --token="": Bearer token for authentication to the API server.
+ --user="": The name of the kubeconfig user to use
+ --username="": Username for basic authentication to the API server.
+ --v=0: log level for V logs
+ --vmodule=: comma-separated list of pattern=N settings for file-filtered logging
+```
+
+### SEE ALSO
+
+* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
+
+###### Auto generated by spf13/cobra on 9-Oct-2015
+
+
+[]()
+
diff --git a/docs/user-guide/kubectl/kubectl_create.md b/docs/user-guide/kubectl/kubectl_create.md
index fc197dcdcd8..505a96260f4 100644
--- a/docs/user-guide/kubectl/kubectl_create.md
+++ b/docs/user-guide/kubectl/kubectl_create.md
@@ -97,7 +97,7 @@ $ cat pod.json | kubectl create -f -
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.399116592 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_delete.md b/docs/user-guide/kubectl/kubectl_delete.md
index fb8a25085e4..93942c4aed3 100644
--- a/docs/user-guide/kubectl/kubectl_delete.md
+++ b/docs/user-guide/kubectl/kubectl_delete.md
@@ -119,7 +119,7 @@ $ kubectl delete pods --all
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.153952299 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290276028 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_describe.md b/docs/user-guide/kubectl/kubectl_describe.md
index 8337c2ddbd6..4ed18fc99f2 100644
--- a/docs/user-guide/kubectl/kubectl_describe.md
+++ b/docs/user-guide/kubectl/kubectl_describe.md
@@ -119,7 +119,7 @@ $ kubectl describe pods frontend
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.152057668 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.289638749 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_edit.md b/docs/user-guide/kubectl/kubectl_edit.md
index 04ef1749998..8d34afb4855 100644
--- a/docs/user-guide/kubectl/kubectl_edit.md
+++ b/docs/user-guide/kubectl/kubectl_edit.md
@@ -114,7 +114,7 @@ kubectl edit (RESOURCE/NAME | -f FILENAME)
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-16 00:43:02.024642139 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290401559 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_exec.md b/docs/user-guide/kubectl/kubectl_exec.md
index 3ea0c61610d..4b91da32b69 100644
--- a/docs/user-guide/kubectl/kubectl_exec.md
+++ b/docs/user-guide/kubectl/kubectl_exec.md
@@ -99,7 +99,7 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.934818621 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_expose.md b/docs/user-guide/kubectl/kubectl_expose.md
index 42748f60a95..5351215ac3f 100644
--- a/docs/user-guide/kubectl/kubectl_expose.md
+++ b/docs/user-guide/kubectl/kubectl_expose.md
@@ -125,7 +125,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-14 01:48:52.452547937 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.292344962 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_get.md b/docs/user-guide/kubectl/kubectl_get.md
index a62e562d6c6..47a19a84185 100644
--- a/docs/user-guide/kubectl/kubectl_get.md
+++ b/docs/user-guide/kubectl/kubectl_get.md
@@ -132,7 +132,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.151532564 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.288852192 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_label.md b/docs/user-guide/kubectl/kubectl_label.md
index 1a0a3fbdc6c..977985787bb 100644
--- a/docs/user-guide/kubectl/kubectl_label.md
+++ b/docs/user-guide/kubectl/kubectl_label.md
@@ -120,7 +120,7 @@ $ kubectl label pods foo bar-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.160594172 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.29251561 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_logs.md b/docs/user-guide/kubectl/kubectl_logs.md
index 9478225f848..39fedcada43 100644
--- a/docs/user-guide/kubectl/kubectl_logs.md
+++ b/docs/user-guide/kubectl/kubectl_logs.md
@@ -109,7 +109,7 @@ $ kubectl logs --since=1h nginx
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-16 18:54:52.319210951 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290730658 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_namespace.md b/docs/user-guide/kubectl/kubectl_namespace.md
index 14dbd6aee2b..24de5bd200a 100644
--- a/docs/user-guide/kubectl/kubectl_namespace.md
+++ b/docs/user-guide/kubectl/kubectl_namespace.md
@@ -79,7 +79,7 @@ kubectl namespace [namespace]
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.154262869 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290510762 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_patch.md b/docs/user-guide/kubectl/kubectl_patch.md
index 7c6b57d6c46..5eef32fbf79 100644
--- a/docs/user-guide/kubectl/kubectl_patch.md
+++ b/docs/user-guide/kubectl/kubectl_patch.md
@@ -102,7 +102,7 @@ kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.153568922 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290134655 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_port-forward.md b/docs/user-guide/kubectl/kubectl_port-forward.md
index 189acda0fc5..f4e711d02af 100644
--- a/docs/user-guide/kubectl/kubectl_port-forward.md
+++ b/docs/user-guide/kubectl/kubectl_port-forward.md
@@ -99,7 +99,7 @@ $ kubectl port-forward mypod 0:5000
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.156433376 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.291494553 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_proxy.md b/docs/user-guide/kubectl/kubectl_proxy.md
index db211b5856e..8b300ea2787 100644
--- a/docs/user-guide/kubectl/kubectl_proxy.md
+++ b/docs/user-guide/kubectl/kubectl_proxy.md
@@ -122,7 +122,7 @@ $ kubectl proxy --api-prefix=/k8s-api
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-30 13:52:13.608206963 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_replace.md b/docs/user-guide/kubectl/kubectl_replace.md
index d4b28afc034..2836c6e16e7 100644
--- a/docs/user-guide/kubectl/kubectl_replace.md
+++ b/docs/user-guide/kubectl/kubectl_replace.md
@@ -111,7 +111,7 @@ kubectl replace --force -f ./pod.json
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.399461456 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_rolling-update.md b/docs/user-guide/kubectl/kubectl_rolling-update.md
index bcccd141ed6..511ea2600c1 100644
--- a/docs/user-guide/kubectl/kubectl_rolling-update.md
+++ b/docs/user-guide/kubectl/kubectl_rolling-update.md
@@ -119,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.40113721 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_run.md b/docs/user-guide/kubectl/kubectl_run.md
index ddc318b266c..993b70c57bd 100644
--- a/docs/user-guide/kubectl/kubectl_run.md
+++ b/docs/user-guide/kubectl/kubectl_run.md
@@ -135,7 +135,7 @@ $ kubectl run nginx --image=nginx --command -- ...
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.93540785 +0000 UTC
+###### Auto generated by spf13/cobra on 9-Oct-2015
[]()
diff --git a/docs/user-guide/kubectl/kubectl_scale.md b/docs/user-guide/kubectl/kubectl_scale.md
index 1589bcf8157..04c9df9002a 100644
--- a/docs/user-guide/kubectl/kubectl_scale.md
+++ b/docs/user-guide/kubectl/kubectl_scale.md
@@ -108,7 +108,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.155304524 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.291112 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_stop.md b/docs/user-guide/kubectl/kubectl_stop.md
index 29bf099afa8..c9dff199329 100644
--- a/docs/user-guide/kubectl/kubectl_stop.md
+++ b/docs/user-guide/kubectl/kubectl_stop.md
@@ -110,7 +110,7 @@ $ kubectl stop -f path/to/resources
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.158360787 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.292142116 +0000 UTC
[]()
diff --git a/docs/user-guide/kubectl/kubectl_version.md b/docs/user-guide/kubectl/kubectl_version.md
index 1b1d2595079..b14c51bda37 100644
--- a/docs/user-guide/kubectl/kubectl_version.md
+++ b/docs/user-guide/kubectl/kubectl_version.md
@@ -82,7 +82,7 @@ kubectl version
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
-###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.164581808 +0000 UTC
+###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294832043 +0000 UTC
[]()
diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go
index 7f504c1cc4b..b52b6716163 100644
--- a/pkg/kubectl/cmd/cmd.go
+++ b/pkg/kubectl/cmd/cmd.go
@@ -174,6 +174,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
cmds.AddCommand(NewCmdApiVersions(f, out))
cmds.AddCommand(NewCmdVersion(f, out))
cmds.AddCommand(NewCmdExplain(f, out))
+ cmds.AddCommand(NewCmdConvert(f, out))
return cmds
}
diff --git a/pkg/kubectl/cmd/convert.go b/pkg/kubectl/cmd/convert.go
new file mode 100644
index 00000000000..8421b46c559
--- /dev/null
+++ b/pkg/kubectl/cmd/convert.go
@@ -0,0 +1,156 @@
+/*
+Copyright 2014 The Kubernetes Authors All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package cmd
+
+import (
+ "fmt"
+ "io"
+
+ "k8s.io/kubernetes/pkg/api/latest"
+ "k8s.io/kubernetes/pkg/api/registered"
+ "k8s.io/kubernetes/pkg/kubectl"
+ cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
+ "k8s.io/kubernetes/pkg/kubectl/resource"
+
+ "github.com/spf13/cobra"
+)
+
+const (
+ convert_long = `Convert config files between different API versions. Both YAML
+and JSON formats are accepted.
+
+The command takes filename, directory, or URL as input, and convert it into format
+of version specified by --output-version flag. If target version is not specified or
+not supported, convert to latest version.
+
+The default output will be printed to stdout in YAML format. One can use -o option
+to change to output destination.
+`
+ convert_example = `# Convert 'pod.yaml' to latest version and print to stdout.
+$ kubectl convert -f pod.yaml
+
+# Convert the live state of the resource specified by 'pod.yaml' to the latest version
+# and print to stdout in json format.
+$ kubectl convert -f pod.yaml --local -o json
+
+# Convert all files under current directory to latest version and create them all.
+$ kubectl convert -f . | kubectl create -f -
+`
+)
+
+// NewCmdConvert creates a command object for the generic "convert" action, which
+// translates the config file into a given version.
+func NewCmdConvert(f *cmdutil.Factory, out io.Writer) *cobra.Command {
+ options := &ConvertOptions{}
+
+ cmd := &cobra.Command{
+ Use: "convert -f FILENAME",
+ Short: "Convert config files between different API versions",
+ Long: convert_long,
+ Example: convert_example,
+ Run: func(cmd *cobra.Command, args []string) {
+ err := options.Complete(f, out, cmd, args)
+ cmdutil.CheckErr(err)
+ err = options.RunConvert()
+ cmdutil.CheckErr(err)
+ },
+ }
+
+ usage := "Filename, directory, or URL to file to need to get converted."
+ kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
+ cmd.MarkFlagRequired("filename")
+ cmdutil.AddValidateFlags(cmd)
+ cmdutil.AddPrinterFlags(cmd)
+ cmd.Flags().BoolVar(&options.local, "local", true, "If true, convert will NOT try to contact api-server but run locally.")
+
+ return cmd
+}
+
+// ConvertOptions have the data required to perform the convert operation
+type ConvertOptions struct {
+ builder *resource.Builder
+ filenames []string
+ local bool
+
+ out io.Writer
+ printer kubectl.ResourcePrinter
+
+ outputVersion string
+}
+
+// Complete collects information required to run Convert command from command line.
+func (o *ConvertOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {
+ o.outputVersion = cmdutil.OutputVersion(cmd, latest.GroupOrDie("").Version)
+ if !registered.IsRegisteredAPIVersion(o.outputVersion) {
+ cmdutil.UsageError(cmd, "'%s' is not a registered version.", o.outputVersion)
+ }
+
+ // build the builder
+ mapper, typer := f.Object()
+ if o.local {
+ fmt.Fprintln(out, "running in local mode...")
+ o.builder = resource.NewBuilder(mapper, typer, f.NilClientMapperForCommand())
+ } else {
+ o.builder = resource.NewBuilder(mapper, typer, f.ClientMapperForCommand())
+ schema, err := f.Validator(cmdutil.GetFlagBool(cmd, "validate"), cmdutil.GetFlagString(cmd, "schema-cache-dir"))
+ if err != nil {
+ return err
+ }
+ o.builder = o.builder.Schema(schema)
+ }
+ cmdNamespace, _, err := f.DefaultNamespace()
+ if err != nil {
+ return err
+ }
+ o.builder = o.builder.NamespaceParam(cmdNamespace).
+ ContinueOnError().
+ FilenameParam(false, o.filenames...).
+ Flatten()
+
+ // build the printer
+ o.out = out
+ outputFormat := cmdutil.GetFlagString(cmd, "output")
+ templateFile := cmdutil.GetFlagString(cmd, "template")
+ if len(outputFormat) == 0 {
+ if len(templateFile) == 0 {
+ outputFormat = "yaml"
+ } else {
+ outputFormat = "template"
+ }
+ }
+ o.printer, _, err = kubectl.GetPrinter(outputFormat, templateFile)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// RunConvert implements the generic Convert command
+func (o *ConvertOptions) RunConvert() error {
+ infos, err := o.builder.Do().Infos()
+ if err != nil {
+ return err
+ }
+
+ objects, err := resource.AsVersionedObject(infos, false, o.outputVersion)
+ if err != nil {
+ return err
+ }
+
+ return o.printer.PrintObj(objects, o.out)
+}
diff --git a/pkg/kubectl/cmd/util/factory.go b/pkg/kubectl/cmd/util/factory.go
index 4981e225dd9..ea41a5f1769 100644
--- a/pkg/kubectl/cmd/util/factory.go
+++ b/pkg/kubectl/cmd/util/factory.go
@@ -532,3 +532,11 @@ func (f *Factory) ClientMapperForCommand() resource.ClientMapper {
return f.RESTClient(mapping)
})
}
+
+// NilClientMapperForCommand returns a ClientMapper which always returns nil.
+// When command is running locally and client isn't needed, this mapper can be parsed to NewBuilder.
+func (f *Factory) NilClientMapperForCommand() resource.ClientMapper {
+ return resource.ClientMapperFunc(func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
+ return nil, nil
+ })
+}
diff --git a/pkg/kubectl/resource/mapper.go b/pkg/kubectl/resource/mapper.go
index a489a6a06c8..a3fc32845e7 100644
--- a/pkg/kubectl/resource/mapper.go
+++ b/pkg/kubectl/resource/mapper.go
@@ -66,6 +66,7 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
if err != nil {
return nil, fmt.Errorf("unable to connect to a server to handle %q: %v", mapping.Resource, err)
}
+
name, _ := mapping.MetadataAccessor.Name(obj)
namespace, _ := mapping.MetadataAccessor.Namespace(obj)
resourceVersion, _ := mapping.MetadataAccessor.ResourceVersion(obj)