From 311385e76c350bf0ab1eb7f401205b150b62a2d2 Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Tue, 2 Feb 2016 13:59:38 -0800 Subject: [PATCH] Make deployment the default in kubectl run --- docs/man/man1/kubectl-run.1 | 8 ++++---- docs/user-guide/deployments.md | 1 - docs/user-guide/kubectl/kubectl_run.md | 10 +++++----- pkg/kubectl/cmd/run.go | 12 +++++------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/docs/man/man1/kubectl-run.1 b/docs/man/man1/kubectl-run.1 index 6ea50079706..9ffe937439d 100644 --- a/docs/man/man1/kubectl-run.1 +++ b/docs/man/man1/kubectl-run.1 @@ -14,7 +14,7 @@ kubectl run \- Run a particular image on the cluster. .SH DESCRIPTION .PP Create and run a particular image, possibly replicated. -Creates a replication controller or job to manage the created container(s). +Creates a deployment or job to manage the created container(s). .SH OPTIONS @@ -40,7 +40,7 @@ Creates a replication controller or job to manage the created container(s). .PP \fB\-\-generator\fP="" - The name of the API generator to use. Default is 'run/v1' if \-\-restart=Always, otherwise the default is 'job/v1beta1'. + The name of the API generator to use. Default is 'deployment/v1beta1' if \-\-restart=Always, otherwise the default is 'job/v1beta1'. .PP \fB\-\-hostport\fP=\-1 @@ -98,7 +98,7 @@ Creates a replication controller or job to manage the created container(s). .PP \fB\-\-restart\fP="Always" - The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, a job is created for this pod and \-\-replicas must be 1. Default 'Always' + The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created for this pod, if set to OnFailure or Never, a job is created for this pod and \-\-replicas must be 1. Default 'Always' .PP \fB\-\-rm\fP=false @@ -256,7 +256,7 @@ $ kubectl run nginx \-\-image=nginx \-\-replicas=5 # Dry run. Print the corresponding API objects without creating them. $ kubectl run nginx \-\-image=nginx \-\-dry\-run -# Start a single instance of nginx, but overload the spec of the replication controller with a partial set of values parsed from JSON. +# Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON. $ kubectl run nginx \-\-image=nginx \-\-overrides='{ "apiVersion": "v1", "spec": { ... } }' # Start a single instance of busybox and keep it in the foreground, don't restart it if it exits. diff --git a/docs/user-guide/deployments.md b/docs/user-guide/deployments.md index c35444415c4..92434de3567 100644 --- a/docs/user-guide/deployments.md +++ b/docs/user-guide/deployments.md @@ -39,7 +39,6 @@ Documentation for other releases can be found at - [Deployments](#deployments) - [What is a _Deployment_?](#what-is-a-deployment) - - [Enabling Deployments on a Kubernetes cluster](#enabling-deployments-on-a-kubernetes-cluster) - [Creating a Deployment](#creating-a-deployment) - [Updating a Deployment](#updating-a-deployment) - [Multiple Updates](#multiple-updates) diff --git a/docs/user-guide/kubectl/kubectl_run.md b/docs/user-guide/kubectl/kubectl_run.md index 887c1239489..f518981f1be 100644 --- a/docs/user-guide/kubectl/kubectl_run.md +++ b/docs/user-guide/kubectl/kubectl_run.md @@ -40,7 +40,7 @@ Run a particular image on the cluster. Create and run a particular image, possibly replicated. -Creates a replication controller or job to manage the created container(s). +Creates a deployment or job to manage the created container(s). ``` kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...] @@ -64,7 +64,7 @@ $ kubectl run nginx --image=nginx --replicas=5 # Dry run. Print the corresponding API objects without creating them. $ kubectl run nginx --image=nginx --dry-run -# Start a single instance of nginx, but overload the spec of the replication controller with a partial set of values parsed from JSON. +# Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON. $ kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }' # Start a single instance of busybox and keep it in the foreground, don't restart it if it exits. @@ -88,7 +88,7 @@ $ kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri --dry-run[=false]: If true, only print the object that would be sent, without sending it. --env=[]: Environment variables to set in the container --expose[=false]: If true, a public, external service is created for the container(s) which are run - --generator="": The name of the API generator to use. Default is 'run/v1' if --restart=Always, otherwise the default is 'job/v1beta1'. + --generator="": The name of the API generator to use. Default is 'deployment/v1beta1' if --restart=Always, otherwise the default is 'job/v1beta1'. --hostport=-1: The host port mapping for the container port. To demonstrate a single-machine container. --image="": The image for the container to run. -l, --labels="": Labels to apply to the pod(s). @@ -102,7 +102,7 @@ $ kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri --record[=false]: Record current kubectl command in the resource annotation. -r, --replicas=1: Number of replicas to create for this container. Default is 1. --requests="": The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi' - --restart="Always": The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, a job is created for this pod and --replicas must be 1. Default 'Always' + --restart="Always": The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created for this pod, if set to OnFailure or Never, a job is created for this pod and --replicas must be 1. Default 'Always' --rm[=false]: If true, delete resources created in this command for attached containers. --save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future. --service-generator="service/v2": The name of the generator to use for creating a service. Only used if --expose is true @@ -147,7 +147,7 @@ $ kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra on 22-Jan-2016 +###### Auto generated by spf13/cobra on 2-Feb-2016 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_run.md?pixel)]() diff --git a/pkg/kubectl/cmd/run.go b/pkg/kubectl/cmd/run.go index 78aba153831..f95759a589e 100644 --- a/pkg/kubectl/cmd/run.go +++ b/pkg/kubectl/cmd/run.go @@ -34,7 +34,7 @@ import ( const ( run_long = `Create and run a particular image, possibly replicated. -Creates a replication controller or job to manage the created container(s).` +Creates a deployment or job to manage the created container(s).` run_example = `# Start a single instance of nginx. $ kubectl run nginx --image=nginx @@ -50,7 +50,7 @@ $ kubectl run nginx --image=nginx --replicas=5 # Dry run. Print the corresponding API objects without creating them. $ kubectl run nginx --image=nginx --dry-run -# Start a single instance of nginx, but overload the spec of the replication controller with a partial set of values parsed from JSON. +# Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON. $ kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }' # Start a single instance of busybox and keep it in the foreground, don't restart it if it exits. @@ -88,8 +88,7 @@ func NewCmdRun(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *c } func addRunFlags(cmd *cobra.Command) { - // TODO: Change the default to "deployment/v1beta1" (which is a valid generator) when deployment reaches beta (#15313) - cmd.Flags().String("generator", "", "The name of the API generator to use. Default is 'run/v1' if --restart=Always, otherwise the default is 'job/v1beta1'.") + cmd.Flags().String("generator", "", "The name of the API generator to use. Default is 'deployment/v1beta1' if --restart=Always, otherwise the default is 'job/v1beta1'.") cmd.Flags().String("image", "", "The image for the container to run.") cmd.MarkFlagRequired("image") cmd.Flags().IntP("replicas", "r", 1, "Number of replicas to create for this container. Default is 1.") @@ -104,7 +103,7 @@ func addRunFlags(cmd *cobra.Command) { cmd.Flags().Bool("tty", false, "Allocated a TTY for each container in the pod. Because -t is currently shorthand for --template, -t is not supported for --tty. This shorthand is deprecated and we expect to adopt -t for --tty soon.") cmd.Flags().Bool("attach", false, "If true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--interactive' is set, in which case the default is true.") cmd.Flags().Bool("leave-stdin-open", false, "If the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes.") - cmd.Flags().String("restart", "Always", "The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, a job is created for this pod and --replicas must be 1. Default 'Always'") + cmd.Flags().String("restart", "Always", "The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created for this pod, if set to OnFailure or Never, a job is created for this pod and --replicas must be 1. Default 'Always'") cmd.Flags().Bool("command", false, "If true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default.") cmd.Flags().String("requests", "", "The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'") cmd.Flags().String("limits", "", "The resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'") @@ -147,9 +146,8 @@ func Run(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cob generatorName := cmdutil.GetFlagString(cmd, "generator") if len(generatorName) == 0 { - // TODO: Change the default to "deployment/v1beta1" when deployment reaches beta (#15313) if restartPolicy == api.RestartPolicyAlways { - generatorName = "run/v1" + generatorName = "deployment/v1beta1" } else { generatorName = "job/v1beta1" }