mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Validate image name for kubectl rolling-update NAME --image=IMAGE
Require distinct image from current one when starting a new rolling-update, and exit with error if an existing in-progress update is targeting a different image.
This commit is contained in:
parent
fd176642d3
commit
5bf993bf28
@ -36,7 +36,7 @@ existing replication controller and overwrite at least one (common) label in its
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-image\fP=""
|
\fB\-\-image\fP=""
|
||||||
Image to use for upgrading the replication controller. Can not be used with \-\-filename/\-f
|
Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with \-\-filename/\-f
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-no\-headers\fP=false
|
\fB\-\-no\-headers\fP=false
|
||||||
|
@ -72,7 +72,7 @@ $ kubectl rolling-update frontend --image=image:v2
|
|||||||
--deployment-label-key="deployment": The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise
|
--deployment-label-key="deployment": The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise
|
||||||
--dry-run[=false]: If true, print out the changes that would be made, but don't actually make them.
|
--dry-run[=false]: If true, print out the changes that would be made, but don't actually make them.
|
||||||
-f, --filename=[]: Filename or URL to file to use to create the new replication controller.
|
-f, --filename=[]: Filename or URL to file to use to create the new replication controller.
|
||||||
--image="": Image to use for upgrading the replication controller. Can not be used with --filename/-f
|
--image="": Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f
|
||||||
--no-headers[=false]: When using the default output, don't print headers.
|
--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].
|
-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).
|
--output-version="": Output the formatted object with the given version (default api-version).
|
||||||
@ -119,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2
|
|||||||
|
|
||||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
###### Auto generated by spf13/cobra on 19-Oct-2015
|
||||||
|
|
||||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||||
[]()
|
[]()
|
||||||
|
@ -90,7 +90,7 @@ func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||||||
usage := "Filename or URL to file to use to create the new replication controller."
|
usage := "Filename or URL to file to use to create the new replication controller."
|
||||||
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
|
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
|
||||||
cmd.MarkFlagRequired("filename")
|
cmd.MarkFlagRequired("filename")
|
||||||
cmd.Flags().String("image", "", "Image to use for upgrading the replication controller. Can not be used with --filename/-f")
|
cmd.Flags().String("image", "", "Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f")
|
||||||
cmd.MarkFlagRequired("image")
|
cmd.MarkFlagRequired("image")
|
||||||
cmd.Flags().String("deployment-label-key", "deployment", "The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise")
|
cmd.Flags().String("deployment-label-key", "deployment", "The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise")
|
||||||
cmd.Flags().Bool("dry-run", false, "If true, print out the changes that would be made, but don't actually make them.")
|
cmd.Flags().Bool("dry-run", false, "If true, print out the changes that would be made, but don't actually make them.")
|
||||||
@ -235,8 +235,14 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if newRc != nil {
|
if newRc != nil {
|
||||||
|
if inProgressImage := newRc.Spec.Template.Spec.Containers[0].Image; inProgressImage != image {
|
||||||
|
return cmdutil.UsageError(cmd, "Found existing in-progress update to image (%s).\nEither continue in-progress update with --image=%s or rollback with --rollback", inProgressImage, inProgressImage)
|
||||||
|
}
|
||||||
fmt.Fprintf(out, "Found existing update in progress (%s), resuming.\n", newRc.Name)
|
fmt.Fprintf(out, "Found existing update in progress (%s), resuming.\n", newRc.Name)
|
||||||
} else {
|
} else {
|
||||||
|
if oldRc.Spec.Template.Spec.Containers[0].Image == image {
|
||||||
|
return cmdutil.UsageError(cmd, "Specified --image must be distinct from existing container image")
|
||||||
|
}
|
||||||
newRc, err = kubectl.CreateNewControllerFromCurrentController(client, cmdNamespace, oldName, newName, image, deploymentKey)
|
newRc, err = kubectl.CreateNewControllerFromCurrentController(client, cmdNamespace, oldName, newName, image, deploymentKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user