Skip to content

Commit

Permalink
Merge pull request #1688 from NeonSludge/skip-init-os
Browse files Browse the repository at this point in the history
feat(kk): allow skipping OS pre-configuration tasks
  • Loading branch information
ks-ci-bot authored Jan 17, 2023
2 parents 8280d60 + a2229f5 commit b6a8ac4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
13 changes: 7 additions & 6 deletions cmd/kk/apis/kubekey/v1alpha2/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ type CustomScripts struct {

// System defines the system config for each node in cluster.
type System struct {
NtpServers []string `yaml:"ntpServers" json:"ntpServers,omitempty"`
Timezone string `yaml:"timezone" json:"timezone,omitempty"`
Rpms []string `yaml:"rpms" json:"rpms,omitempty"`
Debs []string `yaml:"debs" json:"debs,omitempty"`
PreInstall []CustomScripts `yaml:"preInstall" json:"preInstall,omitempty"`
PostInstall []CustomScripts `yaml:"postInstall" json:"postInstall,omitempty"`
NtpServers []string `yaml:"ntpServers" json:"ntpServers,omitempty"`
Timezone string `yaml:"timezone" json:"timezone,omitempty"`
Rpms []string `yaml:"rpms" json:"rpms,omitempty"`
Debs []string `yaml:"debs" json:"debs,omitempty"`
PreInstall []CustomScripts `yaml:"preInstall" json:"preInstall,omitempty"`
PostInstall []CustomScripts `yaml:"postInstall" json:"postInstall,omitempty"`
SkipConfigureOS bool `yaml:"skipConfigureOS" json:"skipConfigureOS,omitempty"`
}

// RegistryConfig defines the configuration information of the image's repository.
Expand Down
5 changes: 5 additions & 0 deletions cmd/kk/pkg/bootstrap/os/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import (

type ConfigureOSModule struct {
common.KubeModule
Skip bool
}

func (c *ConfigureOSModule) IsSkip() bool {
return c.Skip
}

func (c *ConfigureOSModule) Init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/pkg/phase/os/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewConfigOSPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.NodePreCheckModule{},
&os.RepositoryModule{Skip: !runtime.Arg.InstallPackages},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
}

p := pipeline.Pipeline{
Expand Down
6 changes: 3 additions & 3 deletions cmd/kk/pkg/pipelines/add_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewAddNodesPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.NodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall},
&registry.RegistryCertsModule{Skip: len(runtime.GetHostsByRole(common.Registry)) == 0},
&kubernetes.StatusModule{},
Expand Down Expand Up @@ -91,7 +91,7 @@ func NewK3sAddNodesPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K3sNodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall},
&k3s.StatusModule{},
&etcd.PreCheckModule{Skip: runtime.Cluster.Etcd.Type != kubekeyapiv1alpha2.KubeKey},
Expand Down Expand Up @@ -128,7 +128,7 @@ func NewK8eAddNodesPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K8eNodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},

&k8e.StatusModule{},
&etcd.PreCheckModule{Skip: runtime.Cluster.Etcd.Type != kubekeyapiv1alpha2.KubeKey},
Expand Down
6 changes: 3 additions & 3 deletions cmd/kk/pkg/pipelines/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewCreateClusterPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.NodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall},
&kubernetes.StatusModule{},
&container.InstallContainerModule{},
Expand Down Expand Up @@ -145,7 +145,7 @@ func NewK3sCreateClusterPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K3sNodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall},
&k3s.StatusModule{},
&etcd.PreCheckModule{Skip: runtime.Cluster.Etcd.Type != kubekeyapiv1alpha2.KubeKey},
Expand Down Expand Up @@ -219,7 +219,7 @@ func NewK8eCreateClusterPipeline(runtime *common.KubeRuntime) error {
&artifact.UnArchiveModule{Skip: noArtifact},
&os.RepositoryModule{Skip: noArtifact || !runtime.Arg.InstallPackages},
&binaries.K8eNodeBinariesModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall},
&k8e.StatusModule{},
&etcd.PreCheckModule{Skip: runtime.Cluster.Etcd.Type != kubekeyapiv1alpha2.KubeKey},
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/pkg/pipelines/init_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewInitRegistryPipeline(runtime *common.KubeRuntime) error {
&precheck.GreetingsModule{},
&artifact.UnArchiveModule{Skip: noArtifact},
&binaries.RegistryPackageModule{},
&os.ConfigureOSModule{},
&os.ConfigureOSModule{Skip: runtime.Cluster.System.SkipConfigureOS},
&registry.RegistryCertsModule{},
&registry.InstallRegistryModule{},
&filesystem.ChownWorkDirModule{},
Expand Down
3 changes: 2 additions & 1 deletion docs/config-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ spec:
# - name: clean tmps files
# bash: |
# rm -fr /tmp/kubekey/*

#skipConfigureOS: true # Do not pre-configure the host OS (e.g. kernel modules, /etc/hosts, sysctl.conf, NTP servers, etc). You will have to set these things up via other methods before using KubeKey.

kubernetes:
version: v1.21.5
imageRepo: kubesphere
Expand Down

0 comments on commit b6a8ac4

Please sign in to comment.