Add template update to rollingUpdate
This commit is contained in:
		| @@ -55,6 +55,7 @@ var ( | |||||||
| 	www           = flag.String("www", "", "If -proxy is true, use this directory to serve static files") | 	www           = flag.String("www", "", "If -proxy is true, use this directory to serve static files") | ||||||
| 	templateFile  = flag.String("template_file", "", "If present, load this file as a golang template and use it for output printing") | 	templateFile  = flag.String("template_file", "", "If present, load this file as a golang template and use it for output printing") | ||||||
| 	templateStr   = flag.String("template", "", "If present, parse this string as a golang template and use it for output printing") | 	templateStr   = flag.String("template", "", "If present, parse this string as a golang template and use it for output printing") | ||||||
|  | 	imageName     = flag.String("image", "", "Image used when updating a replicationController") | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var parser = kubecfg.NewParser(map[string]interface{}{ | var parser = kubecfg.NewParser(map[string]interface{}{ | ||||||
| @@ -72,7 +73,8 @@ func usage() { | |||||||
|  |  | ||||||
|   Manage replication controllers: |   Manage replication controllers: | ||||||
|   kubecfg [OPTIONS] stop|rm|rollingupdate <controller> |   kubecfg [OPTIONS] stop|rm|rollingupdate <controller> | ||||||
|   kubecfg [OPTIONS] run <image> <replicas> <controller> |   kubecfg [OPTIONS] [-u <time>] [-image image] rollingupdate <controller> | ||||||
|  |   kubecfg [OPTIONS] [-p <port spec>] run <image> <replicas> <controller> | ||||||
|   kubecfg [OPTIONS] resize <controller> <replicas> |   kubecfg [OPTIONS] resize <controller> <replicas> | ||||||
|  |  | ||||||
|   Options: |   Options: | ||||||
| @@ -337,7 +339,7 @@ func executeControllerRequest(method string, c *client.Client) bool { | |||||||
| 	case "rm": | 	case "rm": | ||||||
| 		err = kubecfg.DeleteController(parseController(), c) | 		err = kubecfg.DeleteController(parseController(), c) | ||||||
| 	case "rollingupdate": | 	case "rollingupdate": | ||||||
| 		err = kubecfg.Update(parseController(), c, *updatePeriod) | 		err = kubecfg.Update(parseController(), c, *updatePeriod, *imageName) | ||||||
| 	case "run": | 	case "run": | ||||||
| 		if len(flag.Args()) != 4 { | 		if len(flag.Args()) != 4 { | ||||||
| 			glog.Fatal("usage: kubecfg [OPTIONS] run <image> <replicas> <controller>") | 			glog.Fatal("usage: kubecfg [OPTIONS] run <image> <replicas> <controller>") | ||||||
|   | |||||||
| @@ -78,11 +78,21 @@ func LoadAuthInfo(path string, r io.Reader) (*client.AuthInfo, error) { | |||||||
| // 'name' points to a replication controller. | // 'name' points to a replication controller. | ||||||
| // 'client' is used for updating pods. | // 'client' is used for updating pods. | ||||||
| // 'updatePeriod' is the time between pod updates. | // 'updatePeriod' is the time between pod updates. | ||||||
| func Update(name string, client client.Interface, updatePeriod time.Duration) error { | // 'imageName' is the new image to update to the template | ||||||
|  | func Update(name string, client client.Interface, updatePeriod time.Duration, imageName string) error { | ||||||
| 	controller, err := client.GetReplicationController(name) | 	controller, err := client.GetReplicationController(name) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if len(imageName) != 0 { | ||||||
|  | 		controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image = imageName | ||||||
|  | 		controller, err = client.UpdateReplicationController(controller) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	s := labels.Set(controller.DesiredState.ReplicaSelector).AsSelector() | 	s := labels.Set(controller.DesiredState.ReplicaSelector).AsSelector() | ||||||
|  |  | ||||||
| 	podList, err := client.ListPods(s) | 	podList, err := client.ListPods(s) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Joe Beda
					Joe Beda