1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-13 13:40:22 +00:00

Refactor certificates deployment

This commit is contained in:
moelsayed
2018-02-01 18:25:19 +02:00
parent 8d6c7d303a
commit 8ba6413a44
2 changed files with 34 additions and 72 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/rancher/rke/pki"
"github.com/rancher/rke/services"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
)
func (c *Cluster) TunnelHosts(ctx context.Context, local bool) error {
@@ -72,14 +73,16 @@ func (c *Cluster) InvertIndexHosts() error {
func (c *Cluster) SetUpHosts(ctx context.Context) error {
if c.Authentication.Strategy == X509AuthenticationProvider {
log.Infof(ctx, "[certificates] Deploying kubernetes certificates to Cluster nodes")
if err := pki.DeployCertificatesOnMasters(ctx, c.ControlPlaneHosts, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap); err != nil {
return err
hosts := c.getUniqueHostList()
var errgrp errgroup.Group
for _, host := range hosts {
runHost := host
errgrp.Go(func() error {
return pki.DeployCertificatesOnPlaneHost(ctx, runHost, c.EtcdHosts, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap)
})
}
if err := pki.DeployCertificatesOnWorkers(ctx, c.WorkerHosts, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap); err != nil {
return err
}
// Deploying etcd certificates
if err := pki.DeployCertificatesOnEtcd(ctx, c.EtcdHosts, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap); err != nil {
if err := errgrp.Wait(); err != nil {
return err
}