Add template update to rollingUpdate

pull/6/head
Joe Beda 2014-08-20 10:48:17 -07:00
parent 2444e4e1dc
commit 45aaff9993
2 changed files with 15 additions and 3 deletions

View File

@ -55,6 +55,7 @@ var (
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")
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{}{
@ -72,7 +73,8 @@ func usage() {
Manage replication controllers:
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>
Options:
@ -337,7 +339,7 @@ func executeControllerRequest(method string, c *client.Client) bool {
case "rm":
err = kubecfg.DeleteController(parseController(), c)
case "rollingupdate":
err = kubecfg.Update(parseController(), c, *updatePeriod)
err = kubecfg.Update(parseController(), c, *updatePeriod, *imageName)
case "run":
if len(flag.Args()) != 4 {
glog.Fatal("usage: kubecfg [OPTIONS] run <image> <replicas> <controller>")

View File

@ -78,11 +78,21 @@ func LoadAuthInfo(path string, r io.Reader) (*client.AuthInfo, error) {
// 'name' points to a replication controller.
// 'client' is used for updating pods.
// '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)
if err != nil {
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()
podList, err := client.ListPods(s)