Merge pull request #3537 from brendandburns/cli
Add inline JSON patching to kubectl update ...
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "run-container <name> --image=<image> [--replicas=replicas] [--dry-run=<bool>]",
|
||||
Use: "run-container <name> --image=<image> [--replicas=replicas] [--dry-run=<bool>] [--overrides=<inline-json>]",
|
||||
Short: "Run a particular image on the cluster.",
|
||||
Long: `Create and run a particular image, possibly replicated.
|
||||
Creates a replication controller to manage the created container(s)
|
||||
@@ -40,7 +40,10 @@ Examples:
|
||||
<starts a replicated instance of nginx>
|
||||
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --dry-run
|
||||
<just print the corresponding API objects, don't actually send them to the apiserver>`,
|
||||
<just print the corresponding API objects, don't actually send them to the apiserver>
|
||||
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --overrides='{ "apiVersion": "v1beta1", "desiredState": { ... } }'
|
||||
<start a single instance of nginx, but overload the desired state with a partial set of values parsed from JSON`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 1 {
|
||||
usageError(cmd, "<name> is required for run")
|
||||
@@ -65,6 +68,11 @@ Examples:
|
||||
controller, err := generator.Generate(params)
|
||||
checkErr(err)
|
||||
|
||||
inline := GetFlagString(cmd, "overrides")
|
||||
if len(inline) > 0 {
|
||||
Merge(controller, inline, "ReplicationController")
|
||||
}
|
||||
|
||||
// TODO: extract this flag to a central location, when such a location exists.
|
||||
if !GetFlagBool(cmd, "dry-run") {
|
||||
controller, err = client.ReplicationControllers(namespace).Create(controller.(*api.ReplicationController))
|
||||
@@ -81,5 +89,6 @@ Examples:
|
||||
cmd.Flags().IntP("replicas", "r", 1, "Number of replicas to create for this container. Default 1")
|
||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, don't actually do anything")
|
||||
cmd.Flags().StringP("labels", "l", "", "Labels to apply to the pod(s) created by this call to run.")
|
||||
cmd.Flags().String("overrides", "", "An inline JSON override for the generated object. If this is non-empty, it is parsed used to override the generated object. Requires that the object supply a valid apiVersion field.")
|
||||
return cmd
|
||||
}
|
||||
|
Reference in New Issue
Block a user