Greetings, KubeKey

Signed-off-by: 24sama <jacksama@foxmail.com>
This commit is contained in:
24sama 2022-04-15 14:33:37 +08:00
parent a652437e45
commit 9c1093547e
13 changed files with 61 additions and 0 deletions

View File

@ -120,6 +120,7 @@ func newImagesPushPipeline(runtime *common.KubeRuntime) error {
noArtifact := runtime.Arg.Artifact == ""
m := []module.Module{
&precheck.GreetingsModule{},
&precheck.CRIPreCheckModule{},
&artifact.UnArchiveModule{Skip: noArtifact},
&images.CopyImagesToRegistryModule{ImagePath: runtime.Arg.ImagesDir},

View File

@ -18,10 +18,34 @@ package precheck
import (
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
"github.com/kubesphere/kubekey/pkg/core/prepare"
"github.com/kubesphere/kubekey/pkg/core/task"
"time"
)
type GreetingsModule struct {
module.BaseTaskModule
}
func (h *GreetingsModule) Init() {
h.Name = "GreetingsModule"
h.Desc = "Greetings"
hello := &task.RemoteTask{
Name: "Greetings",
Desc: "Greetings",
Hosts: h.Runtime.GetAllHosts(),
Action: new(GreetingsTask),
Parallel: true,
Timeout: 30 * time.Second,
}
h.Tasks = []task.Interface{
hello,
}
}
type NodePreCheckModule struct {
common.KubeModule
Skip bool

View File

@ -19,7 +19,9 @@ package precheck
import (
"fmt"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/action"
"github.com/kubesphere/kubekey/pkg/core/connector"
"github.com/kubesphere/kubekey/pkg/core/logger"
"github.com/kubesphere/kubekey/pkg/version/kubernetes"
"github.com/kubesphere/kubekey/pkg/version/kubesphere"
"github.com/pkg/errors"
@ -29,6 +31,19 @@ import (
"strings"
)
type GreetingsTask struct {
action.BaseAction
}
func (h *GreetingsTask) Execute(runtime connector.Runtime) error {
hello, err := runtime.GetRunner().SudoCmd("echo 'Greetings, KubeKey!'", false)
if err != nil {
return err
}
logger.Log.Messagef(runtime.RemoteHost().GetName(), hello)
return nil
}
type NodePreCheck struct {
common.KubeAction
}

View File

@ -44,6 +44,7 @@ func NewAddNodesPipeline(runtime *common.KubeRuntime) error {
noArtifact := runtime.Arg.Artifact == ""
m := []module.Module{
&precheck.GreetingsModule{},
&precheck.NodePreCheckModule{},
&confirm.InstallConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},
&artifact.UnArchiveModule{Skip: noArtifact},
@ -101,6 +102,7 @@ func NewK3sAddNodesPipeline(runtime *common.KubeRuntime) error {
noArtifact := runtime.Arg.Artifact == ""
m := []module.Module{
&precheck.GreetingsModule{},
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K3sNodeBinariesModule{},

View File

@ -21,6 +21,7 @@ import (
"github.com/kubesphere/kubekey/pkg/artifact"
"github.com/kubesphere/kubekey/pkg/binaries"
"github.com/kubesphere/kubekey/pkg/bootstrap/confirm"
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
"github.com/kubesphere/kubekey/pkg/core/pipeline"
@ -31,6 +32,7 @@ import (
func NewArtifactExportPipeline(runtime *common.ArtifactRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&confirm.CheckFileExistModule{FileName: runtime.Arg.Output},
&images.CopyImagesToLocalModule{},
&binaries.ArtifactBinariesModule{},
@ -55,6 +57,7 @@ func NewArtifactExportPipeline(runtime *common.ArtifactRuntime) error {
func NewK3sArtifactExportPipeline(runtime *common.ArtifactRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&confirm.CheckFileExistModule{FileName: runtime.Arg.Output},
&images.CopyImagesToLocalModule{},
&binaries.K3sArtifactBinariesModule{},

View File

@ -17,6 +17,7 @@
package pipelines
import (
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/certs"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
@ -25,6 +26,7 @@ import (
func CheckCertsPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&certs.CheckCertsModule{},
&certs.PrintClusterCertsModule{},
}

View File

@ -60,6 +60,7 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
}
m := []module.Module{
&precheck.GreetingsModule{},
&precheck.NodePreCheckModule{},
&confirm.InstallConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},
&artifact.UnArchiveModule{Skip: noArtifact},
@ -155,6 +156,7 @@ func NewK3sCreateClusterPipeline(runtime *common.KubeRuntime) error {
}
m := []module.Module{
&precheck.GreetingsModule{},
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K3sNodeBinariesModule{},

View File

@ -19,6 +19,7 @@ package pipelines
import (
"github.com/kubesphere/kubekey/pkg/bootstrap/confirm"
"github.com/kubesphere/kubekey/pkg/bootstrap/os"
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/certs"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
@ -29,6 +30,7 @@ import (
func NewDeleteClusterPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&confirm.DeleteClusterConfirmModule{},
&kubernetes.ResetClusterModule{},
&os.ClearOSEnvironmentModule{},
@ -48,6 +50,7 @@ func NewDeleteClusterPipeline(runtime *common.KubeRuntime) error {
func NewK3sDeleteClusterPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&confirm.DeleteClusterConfirmModule{},
&k3s.DeleteClusterModule{},
&os.ClearOSEnvironmentModule{},

View File

@ -19,6 +19,7 @@ package pipelines
import (
"github.com/kubesphere/kubekey/pkg/bootstrap/config"
"github.com/kubesphere/kubekey/pkg/bootstrap/confirm"
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
"github.com/kubesphere/kubekey/pkg/core/pipeline"
@ -27,6 +28,7 @@ import (
func DeleteNodePipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&confirm.DeleteNodeConfirmModule{},
&config.ModifyConfigModule{},
&kubernetes.CompareConfigAndClusterInfoModule{},

View File

@ -18,6 +18,7 @@ package pipelines
import (
"github.com/kubesphere/kubekey/pkg/bootstrap/os"
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
"github.com/kubesphere/kubekey/pkg/core/pipeline"
@ -25,6 +26,7 @@ import (
func NewInitDependenciesPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&os.InitDependenciesModule{},
}

View File

@ -21,6 +21,7 @@ import (
"github.com/kubesphere/kubekey/pkg/artifact"
"github.com/kubesphere/kubekey/pkg/binaries"
"github.com/kubesphere/kubekey/pkg/bootstrap/os"
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/bootstrap/registry"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
@ -31,6 +32,7 @@ func NewInitRegistryPipeline(runtime *common.KubeRuntime) error {
noArtifact := runtime.Arg.Artifact == ""
m := []module.Module{
&precheck.GreetingsModule{},
&artifact.UnArchiveModule{Skip: noArtifact},
&binaries.RegistryPackageModule{},
&os.ConfigureOSModule{},

View File

@ -17,6 +17,7 @@
package pipelines
import (
"github.com/kubesphere/kubekey/pkg/bootstrap/precheck"
"github.com/kubesphere/kubekey/pkg/certs"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/module"
@ -25,6 +26,7 @@ import (
func RenewCertsPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&certs.RenewCertsModule{},
&certs.CheckCertsModule{},
&certs.PrintClusterCertsModule{},

View File

@ -37,6 +37,7 @@ func NewUpgradeClusterPipeline(runtime *common.KubeRuntime) error {
noArtifact := runtime.Arg.Artifact == ""
m := []module.Module{
&precheck.GreetingsModule{},
&precheck.NodePreCheckModule{},
&precheck.ClusterPreCheckModule{},
&confirm.UpgradeConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},