mirror of https://github.com/k3s-io/k3s
Add template update to rollingUpdate
parent
2444e4e1dc
commit
45aaff9993
|
@ -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>")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue