1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-05 09:00:31 +00:00
rke/services/workerplane.go

73 lines
1.6 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"
)
2017-11-09 19:50:49 +00:00
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
err := runKubelet(host, workerServices.Kubelet, true)
if err != nil {
return err
}
err = runKubeproxy(host, workerServices.Kubeproxy)
if err != nil {
return err
}
}
for _, host := range workerHosts {
// run nginx proxy
err := runNginxProxy(host, controlHosts)
if err != nil {
return err
}
// run kubelet
err = runKubelet(host, workerServices.Kubelet, false)
if err != nil {
return err
}
// run kubeproxy
err = runKubeproxy(host, workerServices.Kubeproxy)
if err != nil {
return err
}
}
logrus.Infof("[%s] Successfully started Worker Plane..", WorkerRole)
return nil
}
func RemoveWorkerPlane(controlHosts []hosts.Host, workerHosts []hosts.Host) error {
logrus.Infof("[%s] Tearing down Worker Plane..", WorkerRole)
for _, host := range controlHosts {
err := removeKubelet(host)
if err != nil {
return err
}
err = removeKubeproxy(host)
if err != nil {
return err
}
}
for _, host := range workerHosts {
err := removeKubelet(host)
if err != nil {
return err
}
err = removeKubeproxy(host)
if err != nil {
return err
}
err = removeNginxProxy(host)
if err != nil {
return err
}
}
logrus.Infof("[%s] Successfully teared down Worker Plane..", WorkerRole)
return nil
}