1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-14 06:00:53 +00:00
Files
rke/services/controlplane.go

77 lines
2.0 KiB
Go
Raw Normal View History

2017-10-29 11:45:21 +02:00
package services
import (
"github.com/rancher/rke/hosts"
2017-11-14 20:11:21 +02:00
"github.com/rancher/types/apis/cluster.cattle.io/v1"
2017-11-13 23:28:38 +02:00
"github.com/sirupsen/logrus"
2017-10-29 11:45:21 +02:00
)
2017-11-09 21:50:49 +02:00
func RunControlPlane(controlHosts []hosts.Host, etcdHosts []hosts.Host, controlServices v1.RKEConfigServices) error {
logrus.Infof("[%s] Building up Controller Plane..", ControlRole)
for _, host := range controlHosts {
2017-10-29 11:45:21 +02:00
// run kubeapi
err := runKubeAPI(host, etcdHosts, controlServices.KubeAPI)
2017-10-29 11:45:21 +02:00
if err != nil {
return err
}
// run kubecontroller
err = runKubeController(host, controlServices.KubeController)
2017-10-29 11:45:21 +02:00
if err != nil {
return err
}
// run scheduler
err = runScheduler(host, controlServices.Scheduler)
2017-10-29 11:45:21 +02:00
if err != nil {
return err
}
}
logrus.Infof("[%s] Successfully started Controller Plane..", ControlRole)
2017-10-29 11:45:21 +02:00
return nil
}
func UpgradeControlPlane(controlHosts []hosts.Host, etcdHosts []hosts.Host, controlServices v1.RKEConfigServices) error {
logrus.Infof("[%s] Upgrading the Controller Plane..", ControlRole)
for _, host := range controlHosts {
// upgrade KubeAPI
if err := upgradeKubeAPI(host, etcdHosts, controlServices.KubeAPI); err != nil {
return err
}
// upgrade KubeController
if err := upgradeKubeController(host, controlServices.KubeController); err != nil {
return nil
}
// upgrade scheduler
err := upgradeScheduler(host, controlServices.Scheduler)
if err != nil {
return err
}
}
logrus.Infof("[%s] Successfully upgraded Controller Plane..", ControlRole)
return nil
}
func RemoveControlPlane(controlHosts []hosts.Host) error {
logrus.Infof("[%s] Tearing down the Controller Plane..", ControlRole)
for _, host := range controlHosts {
// remove KubeAPI
if err := removeKubeAPI(host); err != nil {
return err
}
// remove KubeController
if err := removeKubeController(host); err != nil {
return nil
}
// remove scheduler
err := removeScheduler(host)
if err != nil {
return err
}
}
logrus.Infof("[%s] Successfully teared down Controller Plane..", ControlRole)
return nil
}