1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-16 15:10:12 +00:00

Command overhaul

remove cluster command
merge upgrade and up commands
rename down command
This commit is contained in:
moelsayed
2017-11-28 13:26:15 +02:00
parent 8f77e50465
commit 07a1441826
17 changed files with 297 additions and 569 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/rancher/rke/hosts"
"github.com/rancher/rke/pki"
"github.com/rancher/types/apis/cluster.cattle.io/v1"
"github.com/sirupsen/logrus"
)
func runKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeAPIService) error {
@@ -18,31 +17,6 @@ func runKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeA
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeAPIContainerName, host.AdvertisedHostname, ControlRole)
}
func upgradeKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeAPIService) error {
logrus.Debugf("[upgrade/KubeAPI] Checking for deployed version")
containerInspect, err := docker.InspectContainer(host.DClient, host.AdvertisedHostname, KubeAPIContainerName)
if err != nil {
return err
}
if containerInspect.Config.Image == kubeAPIService.Image {
logrus.Infof("[upgrade/KubeAPI] KubeAPI is already up to date")
return nil
}
logrus.Debugf("[upgrade/KubeAPI] Stopping old container")
oldContainerName := "old-" + KubeAPIContainerName
if err := docker.StopRenameContainer(host.DClient, host.AdvertisedHostname, KubeAPIContainerName, oldContainerName); err != nil {
return err
}
// Container doesn't exist now!, lets deploy it!
logrus.Debugf("[upgrade/KubeAPI] Deploying new container")
if err := runKubeAPI(host, etcdHosts, kubeAPIService); err != nil {
return err
}
logrus.Debugf("[upgrade/KubeAPI] Removing old container")
err = docker.RemoveContainer(host.DClient, host.AdvertisedHostname, oldContainerName)
return err
}
func removeKubeAPI(host hosts.Host) error {
return docker.DoRemoveContainer(host.DClient, KubeAPIContainerName, host.AdvertisedHostname)
}