1
0
mirror of https://github.com/rancher/rke.git synced 2025-06-23 14:07:13 +00:00
rke/services/workerplane.go

63 lines
1.7 KiB
Go
Raw Normal View History

package services
import (
"github.com/rancher/rke/hosts"
2017-11-14 18:11:21 +00:00
"github.com/rancher/types/apis/cluster.cattle.io/v1"
2017-11-13 21:28:38 +00:00
"github.com/sirupsen/logrus"
)
func RunWorkerPlane(controlHosts []*hosts.Host, workerHosts []*hosts.Host, workerServices v1.RKEConfigServices) error {
logrus.Infof("[%s] Building up Worker Plane..", WorkerRole)
for _, host := range controlHosts {
// only one master for now
2017-11-30 01:41:17 +00:00
if err := runKubelet(host, workerServices.Kubelet); err != nil {
return err
}
2017-11-29 23:18:12 +00:00
if err := runKubeproxy(host, workerServices.Kubeproxy); err != nil {
return err
}
}
for _, host := range workerHosts {
// run nginx proxy
if !host.IsControl {
2017-11-29 23:18:12 +00:00
if err := runNginxProxy(host, controlHosts); err != nil {
return err
}
}
// run kubelet
2017-11-30 01:41:17 +00:00
if err := runKubelet(host, workerServices.Kubelet); err != nil {
return err
}
// run kubeproxy
2017-11-29 23:18:12 +00:00
if err := runKubeproxy(host, workerServices.Kubeproxy); err != nil {
return err
}
}
logrus.Infof("[%s] Successfully started Worker Plane..", WorkerRole)
return nil
}
func RemoveWorkerPlane(workerHosts []*hosts.Host, force bool) error {
logrus.Infof("[%s] Tearing down Worker Plane..", WorkerRole)
for _, host := range workerHosts {
// check if the host already is a controlplane
if host.IsControl && !force {
logrus.Infof("[%s] Host [%s] is already a controlplane host, nothing to do.", WorkerRole, host.Address)
return nil
}
2017-11-29 23:18:12 +00:00
if err := removeKubelet(host); err != nil {
return err
}
2017-11-29 23:18:12 +00:00
if err := removeKubeproxy(host); err != nil {
return err
}
2017-11-29 23:18:12 +00:00
if err := removeNginxProxy(host); err != nil {
return err
}
logrus.Infof("[%s] Successfully teared down Worker Plane..", WorkerRole)
}
return nil
}