Skip to content

Commit

Permalink
Merge pull request #896 from tanguofu/master
Browse files Browse the repository at this point in the history
fix(kk): #889 Remove AddonsModule must need a network plugin enabled
  • Loading branch information
ks-ci-bot committed Dec 17, 2021
2 parents 213541c + 4d9b1f8 commit 44d0263
Showing 1 changed file with 59 additions and 40 deletions.
99 changes: 59 additions & 40 deletions pkg/pipelines/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ package pipelines
import (
"encoding/base64"
"fmt"
"io/ioutil"
"path/filepath"

kubekeycontroller "github.com/kubesphere/kubekey/controllers/kubekey"
"github.com/kubesphere/kubekey/pkg/addons"
"github.com/kubesphere/kubekey/pkg/binaries"
Expand All @@ -41,12 +44,9 @@ import (
"github.com/kubesphere/kubekey/pkg/plugins/dns"
"github.com/kubesphere/kubekey/pkg/plugins/network"
"github.com/kubesphere/kubekey/pkg/plugins/storage"
"io/ioutil"
"path/filepath"
)

func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
noNetworkPlugin := runtime.Cluster.Network.Plugin == "" || runtime.Cluster.Network.Plugin == "none"

m := []module.Module{
&precheck.NodePreCheckModule{},
Expand All @@ -71,10 +71,10 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
&filesystem.ChownModule{},
&certs.AutoRenewCertsModule{},
&kubernetes.SaveKubeConfigModule{},
&addons.AddonsModule{Skip: noNetworkPlugin},
&storage.DeployLocalVolumeModule{Skip: noNetworkPlugin || (!runtime.Arg.DeployLocalStorage && !runtime.Cluster.KubeSphere.Enabled)},
&kubesphere.DeployModule{Skip: noNetworkPlugin || !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.CheckResultModule{Skip: noNetworkPlugin || !runtime.Cluster.KubeSphere.Enabled},
&addons.AddonsModule{},
&storage.DeployLocalVolumeModule{Skip: !runtime.Arg.DeployLocalStorage && !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.DeployModule{Skip: !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.CheckResultModule{Skip: !runtime.Cluster.KubeSphere.Enabled},
}

p := pipeline.Pipeline{
Expand All @@ -87,30 +87,40 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
return err
}

if runtime.Cluster.KubeSphere.Enabled && !noNetworkPlugin {
if runtime.Cluster.KubeSphere.Enabled {

fmt.Print(`Installation is complete.
Please check the result using the command:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
`)
} else {
if runtime.Arg.InCluster {
if err := kubekeycontroller.UpdateStatus(runtime); err != nil {
fmt.Print(`Installation is complete.
Please check the result using the command:
kubectl get pod -A
`)

}

if runtime.Arg.InCluster {
if err := kubekeycontroller.UpdateStatus(runtime); err != nil {
return err
}
kkConfigPath := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.ObjName))
if config, err := ioutil.ReadFile(kkConfigPath); err != nil {
return err
} else {
runtime.Kubeconfig = base64.StdEncoding.EncodeToString(config)
if err := kubekeycontroller.UpdateKubeSphereCluster(runtime); err != nil {
return err
}
kkConfigPath := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.ObjName))
if config, err := ioutil.ReadFile(kkConfigPath); err != nil {
if err := kubekeycontroller.SaveKubeConfig(runtime); err != nil {
return err
} else {
runtime.Kubeconfig = base64.StdEncoding.EncodeToString(config)
if err := kubekeycontroller.UpdateKubeSphereCluster(runtime); err != nil {
return err
}
if err := kubekeycontroller.SaveKubeConfig(runtime); err != nil {
return err
}
}
}
}
Expand All @@ -119,7 +129,6 @@ Please check the result using the command:
}

func NewK3sCreateClusterPipeline(runtime *common.KubeRuntime) error {
noNetworkPlugin := runtime.Cluster.Network.Plugin == "" || runtime.Cluster.Network.Plugin == "none"

m := []module.Module{
&binaries.K3sNodeBinariesModule{},
Expand All @@ -138,10 +147,10 @@ func NewK3sCreateClusterPipeline(runtime *common.KubeRuntime) error {
&network.DeployNetworkPluginModule{},
&filesystem.ChownModule{},
&k3s.SaveKubeConfigModule{},
&addons.AddonsModule{Skip: noNetworkPlugin},
&storage.DeployLocalVolumeModule{Skip: noNetworkPlugin || (!runtime.Arg.DeployLocalStorage && !runtime.Cluster.KubeSphere.Enabled)},
&kubesphere.DeployModule{Skip: noNetworkPlugin || !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.CheckResultModule{Skip: noNetworkPlugin || !runtime.Cluster.KubeSphere.Enabled},
&addons.AddonsModule{},
&storage.DeployLocalVolumeModule{Skip: !runtime.Arg.DeployLocalStorage && !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.DeployModule{Skip: !runtime.Cluster.KubeSphere.Enabled},
&kubesphere.CheckResultModule{Skip: !runtime.Cluster.KubeSphere.Enabled},
}

p := pipeline.Pipeline{
Expand All @@ -154,30 +163,40 @@ func NewK3sCreateClusterPipeline(runtime *common.KubeRuntime) error {
return err
}

if runtime.Cluster.KubeSphere.Enabled && !noNetworkPlugin {
if runtime.Cluster.KubeSphere.Enabled {

fmt.Print(`Installation is complete.
Please check the result using the command:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
`)
} else {
if runtime.Arg.InCluster {
if err := kubekeycontroller.UpdateStatus(runtime); err != nil {
fmt.Print(`Installation is complete.
Please check the result using the command:
kubectl get pod -A
`)

}

if runtime.Arg.InCluster {
if err := kubekeycontroller.UpdateStatus(runtime); err != nil {
return err
}
kkConfigPath := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.ObjName))
if config, err := ioutil.ReadFile(kkConfigPath); err != nil {
return err
} else {
runtime.Kubeconfig = base64.StdEncoding.EncodeToString(config)
if err := kubekeycontroller.UpdateKubeSphereCluster(runtime); err != nil {
return err
}
kkConfigPath := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.ObjName))
if config, err := ioutil.ReadFile(kkConfigPath); err != nil {
if err := kubekeycontroller.SaveKubeConfig(runtime); err != nil {
return err
} else {
runtime.Kubeconfig = base64.StdEncoding.EncodeToString(config)
if err := kubekeycontroller.UpdateKubeSphereCluster(runtime); err != nil {
return err
}
if err := kubekeycontroller.SaveKubeConfig(runtime); err != nil {
return err
}
}
}
}
Expand Down

0 comments on commit 44d0263

Please sign in to comment.