mirror of
https://github.com/rancher/rke.git
synced 2025-05-09 00:37:01 +00:00
rke refactoring - configure cluster method
This commit is contained in:
parent
9a234ccb4e
commit
d99efdc60f
@ -22,14 +22,14 @@ type ingressOptions struct {
|
||||
NodeSelector map[string]string
|
||||
}
|
||||
|
||||
func (c *Cluster) DeployK8sAddOns(ctx context.Context) error {
|
||||
func (c *Cluster) deployK8sAddOns(ctx context.Context) error {
|
||||
if err := c.deployKubeDNS(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.deployIngress(ctx)
|
||||
}
|
||||
|
||||
func (c *Cluster) DeployUserAddOns(ctx context.Context) error {
|
||||
func (c *Cluster) deployUserAddOns(ctx context.Context) error {
|
||||
log.Infof(ctx, "[addons] Setting up user addons..")
|
||||
if c.Addons == "" {
|
||||
log.Infof(ctx, "[addons] No user addons configured..")
|
||||
|
@ -255,11 +255,11 @@ func (c *Cluster) getUniqueHostList() []*hosts.Host {
|
||||
return uniqHostList
|
||||
}
|
||||
|
||||
func (c *Cluster) DeployAddons(ctx context.Context) error {
|
||||
if err := c.DeployK8sAddOns(ctx); err != nil {
|
||||
func (c *Cluster) deployAddons(ctx context.Context) error {
|
||||
if err := c.deployK8sAddOns(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.DeployUserAddOns(ctx)
|
||||
return c.deployUserAddOns(ctx)
|
||||
}
|
||||
|
||||
func (c *Cluster) SyncLabelsAndTaints(ctx context.Context) error {
|
||||
@ -297,3 +297,18 @@ func (c *Cluster) PrePullK8sImages(ctx context.Context) error {
|
||||
log.Infof(ctx, "Kubernetes images pulled successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
func ConfigureCluster(ctx context.Context, rkeConfig v3.RancherKubernetesEngineConfig, crtBundle map[string]pki.CertificatePKI, clusterFilePath, configDir string) error {
|
||||
// dialer factories are not needed here since we are not uses docker only k8s jobs
|
||||
kubeCluster, err := ParseCluster(ctx, &rkeConfig, clusterFilePath, configDir, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kubeCluster.Certificates = crtBundle
|
||||
err = kubeCluster.deployNetworkPlugin(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return kubeCluster.deployAddons(ctx)
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ const (
|
||||
RBACConfig = "RBACConfig"
|
||||
)
|
||||
|
||||
func (c *Cluster) DeployNetworkPlugin(ctx context.Context) error {
|
||||
func (c *Cluster) deployNetworkPlugin(ctx context.Context) error {
|
||||
log.Infof(ctx, "[network] Setting up network plugin: %s", c.Network.Plugin)
|
||||
switch c.Network.Plugin {
|
||||
case FlannelNetworkPlugin:
|
||||
|
@ -97,17 +97,12 @@ func ClusterUp(
|
||||
return APIURL, caCrt, clientCert, clientKey, err
|
||||
}
|
||||
|
||||
err = kubeCluster.DeployNetworkPlugin(ctx)
|
||||
if err != nil {
|
||||
return APIURL, caCrt, clientCert, clientKey, err
|
||||
}
|
||||
|
||||
err = kubeCluster.SyncLabelsAndTaints(ctx)
|
||||
if err != nil {
|
||||
return APIURL, caCrt, clientCert, clientKey, err
|
||||
}
|
||||
|
||||
err = kubeCluster.DeployAddons(ctx)
|
||||
err = cluster.ConfigureCluster(ctx, kubeCluster.RancherKubernetesEngineConfig, kubeCluster.Certificates, clusterFilePath, configDir)
|
||||
if err != nil {
|
||||
return APIURL, caCrt, clientCert, clientKey, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user