From 6c1581d355fd5e37cd765fe73ab04c0271a32ccf Mon Sep 17 00:00:00 2001 From: rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Wed, 5 Jul 2023 10:21:25 +0800 Subject: [PATCH 1/2] feat: add an initial stage at the very start cluster creating phase --- cmd/kk/apis/kubekey/v1alpha2/cluster_types.go | 1 + cmd/kk/pkg/pipelines/create_cluster.go | 1 + docs/config-example.md | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go b/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go index 1a304e15..13b1e2dc 100644 --- a/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go +++ b/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go @@ -92,6 +92,7 @@ type CustomScripts struct { // System defines the system config for each node in cluster. type System struct { + Initials []CustomScripts `yaml:"initials" json:"initials,omitempty"` NtpServers []string `yaml:"ntpServers" json:"ntpServers,omitempty"` Timezone string `yaml:"timezone" json:"timezone,omitempty"` Rpms []string `yaml:"rpms" json:"rpms,omitempty"` diff --git a/cmd/kk/pkg/pipelines/create_cluster.go b/cmd/kk/pkg/pipelines/create_cluster.go index cfe31a3b..fcf7c7e4 100644 --- a/cmd/kk/pkg/pipelines/create_cluster.go +++ b/cmd/kk/pkg/pipelines/create_cluster.go @@ -58,6 +58,7 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error { m := []module.Module{ &precheck.GreetingsModule{}, + &customscripts.CustomScriptsModule{Phase: "Initial", Scripts: runtime.Cluster.System.Initials}, &precheck.NodePreCheckModule{}, &confirm.InstallConfirmModule{}, &artifact.UnArchiveModule{Skip: noArtifact}, diff --git a/docs/config-example.md b/docs/config-example.md index 54dce754..479cb5c6 100644 --- a/docs/config-example.md +++ b/docs/config-example.md @@ -42,7 +42,16 @@ spec: # Specify additional packages to be installed. The ISO file which is contained in the artifact is required. debs: - nfs-common - #preInstall: # Specify custom init shell scripts for each nodes, and execute according to the list order. + # initials: + # - name: Install hd tool + # bash: curl https://gitee.com/linuxsuren/tools/raw/master/install-zh.sh|bash + # - name: Install packages + # bash: | + # hd setup --proxy ghproxy.com --provider gitee + # hd i chrony + # hd i conntrack + # hd i socat + #preInstall: # Specify custom init shell scripts for each nodes, and execute according to the list order before install container runtime. # - name: format and mount disk # bash: /bin/bash -x setup-disk.sh # materials: # scripts can has some dependency materials. those will copy to the node From c098865f002901fbc1b08d5e0a775b50a8ea70e3 Mon Sep 17 00:00:00 2001 From: rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:10:32 +0800 Subject: [PATCH 2/2] move the preInstall into the first stage --- cmd/kk/apis/kubekey/v1alpha2/cluster_types.go | 1 - cmd/kk/pkg/pipelines/create_cluster.go | 3 +-- docs/config-example.md | 13 ++----------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go b/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go index 13b1e2dc..1a304e15 100644 --- a/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go +++ b/cmd/kk/apis/kubekey/v1alpha2/cluster_types.go @@ -92,7 +92,6 @@ type CustomScripts struct { // System defines the system config for each node in cluster. type System struct { - Initials []CustomScripts `yaml:"initials" json:"initials,omitempty"` NtpServers []string `yaml:"ntpServers" json:"ntpServers,omitempty"` Timezone string `yaml:"timezone" json:"timezone,omitempty"` Rpms []string `yaml:"rpms" json:"rpms,omitempty"` diff --git a/cmd/kk/pkg/pipelines/create_cluster.go b/cmd/kk/pkg/pipelines/create_cluster.go index fcf7c7e4..5c2224c4 100644 --- a/cmd/kk/pkg/pipelines/create_cluster.go +++ b/cmd/kk/pkg/pipelines/create_cluster.go @@ -58,14 +58,13 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error { m := []module.Module{ &precheck.GreetingsModule{}, - &customscripts.CustomScriptsModule{Phase: "Initial", Scripts: runtime.Cluster.System.Initials}, + &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &precheck.NodePreCheckModule{}, &confirm.InstallConfirmModule{}, &artifact.UnArchiveModule{Skip: noArtifact}, &os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages}, &binaries.NodeBinariesModule{}, &os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS}, - &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, &container.InstallContainerModule{}, &images.CopyImagesToRegistryModule{Skip: skipPushImages}, diff --git a/docs/config-example.md b/docs/config-example.md index 479cb5c6..8370dc34 100644 --- a/docs/config-example.md +++ b/docs/config-example.md @@ -42,22 +42,13 @@ spec: # Specify additional packages to be installed. The ISO file which is contained in the artifact is required. debs: - nfs-common - # initials: - # - name: Install hd tool - # bash: curl https://gitee.com/linuxsuren/tools/raw/master/install-zh.sh|bash - # - name: Install packages - # bash: | - # hd setup --proxy ghproxy.com --provider gitee - # hd i chrony - # hd i conntrack - # hd i socat - #preInstall: # Specify custom init shell scripts for each nodes, and execute according to the list order before install container runtime. + #preInstall: # Specify custom init shell scripts for each nodes, and execute according to the list order at the first stage. # - name: format and mount disk # bash: /bin/bash -x setup-disk.sh # materials: # scripts can has some dependency materials. those will copy to the node # - ./setup-disk.sh # the script which shell execute need # - xxx # other tools materials need by this script - #postInstall: # Specify custom finish clean up shell scripts for each nodes after the kubernetes install. + #postInstall: # Specify custom finish clean up shell scripts for each nodes after the Kubernetes install. # - name: clean tmps files # bash: | # rm -fr /tmp/kubekey/*