mirror of
https://github.com/rancher/rke.git
synced 2025-08-11 03:32:45 +00:00
Add concurrency to worker deployments
This commit is contained in:
parent
5ac6a22c39
commit
828f6e44f5
@ -4,43 +4,32 @@ import (
|
|||||||
"github.com/rancher/rke/hosts"
|
"github.com/rancher/rke/hosts"
|
||||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunWorkerPlane(controlHosts, workerHosts []*hosts.Host, workerServices v3.RKEConfigServices, nginxProxyImage, sidekickImage string, healthcheckDialerFactory hosts.DialerFactory) error {
|
func RunWorkerPlane(controlHosts, workerHosts []*hosts.Host, workerServices v3.RKEConfigServices, nginxProxyImage, sidekickImage string, healthcheckDialerFactory hosts.DialerFactory) error {
|
||||||
logrus.Infof("[%s] Building up Worker Plane..", WorkerRole)
|
logrus.Infof("[%s] Building up Worker Plane..", WorkerRole)
|
||||||
|
var errgrp errgroup.Group
|
||||||
|
|
||||||
|
// Deploy worker components on control hosts
|
||||||
for _, host := range controlHosts {
|
for _, host := range controlHosts {
|
||||||
// run sidekick
|
controlHost := host
|
||||||
if err := runSidekick(host, sidekickImage); err != nil {
|
errgrp.Go(func() error {
|
||||||
return err
|
return doDeployWorkerPlane(controlHost, workerServices, nginxProxyImage, sidekickImage, healthcheckDialerFactory, controlHosts)
|
||||||
}
|
})
|
||||||
// run kubelet
|
|
||||||
// only one master for now
|
|
||||||
if err := runKubelet(host, workerServices.Kubelet, healthcheckDialerFactory); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := runKubeproxy(host, workerServices.Kubeproxy, healthcheckDialerFactory); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if err := errgrp.Wait(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Deploy worker components on worker hosts
|
||||||
for _, host := range workerHosts {
|
for _, host := range workerHosts {
|
||||||
// run nginx proxy
|
workerHost := host
|
||||||
if !host.IsControl {
|
errgrp.Go(func() error {
|
||||||
if err := runNginxProxy(host, controlHosts, nginxProxyImage); err != nil {
|
return doDeployWorkerPlane(workerHost, workerServices, nginxProxyImage, sidekickImage, healthcheckDialerFactory, controlHosts)
|
||||||
return err
|
})
|
||||||
}
|
}
|
||||||
}
|
if err := errgrp.Wait(); err != nil {
|
||||||
// run sidekick
|
return err
|
||||||
if err := runSidekick(host, sidekickImage); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// run kubelet
|
|
||||||
if err := runKubelet(host, workerServices.Kubelet, healthcheckDialerFactory); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// run kubeproxy
|
|
||||||
if err := runKubeproxy(host, workerServices.Kubeproxy, healthcheckDialerFactory); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
logrus.Infof("[%s] Successfully started Worker Plane..", WorkerRole)
|
logrus.Infof("[%s] Successfully started Worker Plane..", WorkerRole)
|
||||||
return nil
|
return nil
|
||||||
@ -72,3 +61,25 @@ func RemoveWorkerPlane(workerHosts []*hosts.Host, force bool) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doDeployWorkerPlane(host *hosts.Host,
|
||||||
|
workerServices v3.RKEConfigServices,
|
||||||
|
nginxProxyImage, sidekickImage string,
|
||||||
|
healthcheckDialerFactory hosts.DialerFactory,
|
||||||
|
controlHosts []*hosts.Host) error {
|
||||||
|
// run nginx proxy
|
||||||
|
if !host.IsControl {
|
||||||
|
if err := runNginxProxy(host, controlHosts, nginxProxyImage); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// run sidekick
|
||||||
|
if err := runSidekick(host, sidekickImage); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// run kubelet
|
||||||
|
if err := runKubelet(host, workerServices.Kubelet, healthcheckDialerFactory); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return runKubeproxy(host, workerServices.Kubeproxy, healthcheckDialerFactory)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user