Skip to content

Commit

Permalink
Merge pull request #1329 from 24sama/master
Browse files Browse the repository at this point in the history
fix: the generated kk config file contains the "containerManager" by default
  • Loading branch information
ks-ci-bot authored Jun 10, 2022
2 parents 2d11619 + c9a7f1c commit 27207af
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,22 @@ Quick Start is for `all-in-one` installation which is a good start to get famili

##### Examples

* Create a pure Kubernetes cluster with default version.
* Create a pure Kubernetes cluster with default version (Kubernetes v1.23.7).

```shell script
./kk create cluster
```

* Create a Kubernetes cluster with a specified version (e.g. `--with-kubernetes v1.24.1`).
* Create a Kubernetes cluster with a specified version.

```shell script
./kk create cluster --with-kubernetes [version]
./kk create cluster --with-kubernetes v1.24.1 --container-manager containerd
```

* Create a Kubernetes cluster with KubeSphere installed (e.g. `--with-kubesphere v3.2.1`).
* Create a Kubernetes cluster with KubeSphere installed.

```shell script
./kk create cluster --with-kubesphere [version]
./kk create cluster --with-kubesphere v3.2.1
```

#### Advanced
Expand Down
10 changes: 10 additions & 0 deletions pkg/config/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"

"github.com/pkg/errors"
versionutil "k8s.io/apimachinery/pkg/util/version"

kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/pkg/common"
Expand Down Expand Up @@ -57,6 +58,15 @@ func GenerateKubeKeyConfig(arg common.Argument, name string) error {
} else {
opt.KubeVersion = arg.KubernetesVersion
}

if k8sVersion, err := versionutil.ParseGeneric(opt.KubeVersion); err == nil {
if k8sVersion.AtLeast(versionutil.MustParseSemantic("v1.24.0")) {
opt.ContainerManager = common.Conatinerd
} else {
opt.ContainerManager = common.Docker
}
}

opt.KubeSphereEnabled = arg.KsEnable

if arg.KsEnable {
Expand Down
9 changes: 5 additions & 4 deletions pkg/config/templates/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package templates
import (
"text/template"

kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/pkg/core/util"
"github.com/lithammer/dedent"

"github.com/kubesphere/kubekey/pkg/core/util"
)

// Cluster defines the template of cluster configuration file default.
Expand Down Expand Up @@ -54,6 +54,7 @@ spec:
version: {{ .Options.KubeVersion }}
clusterName: cluster.local
autoRenewCerts: true
containerManager: {{ .Options.ContainerManager }}
etcd:
type: kubekey
network:
Expand Down Expand Up @@ -81,12 +82,12 @@ type Options struct {
KubeVersion string
KubeSphereEnabled bool
KubeSphereConfigMap string
ContainerManager string
}

// GenerateCluster is used to generate cluster configuration content.
func GenerateCluster(opt *Options) (string, error) {
return util.Render(Cluster, util.Data{
"KubeVersion": kubekeyapiv1alpha2.DefaultKubeVersion,
"Options": opt,
"Options": opt,
})
}
5 changes: 4 additions & 1 deletion pkg/kubernetes/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ func (f *FindNode) Execute(runtime connector.Runtime) error {
}

if node == "" {
return errors.New("Please check the node name in the config-sample.yaml or only support to delete a worker")
return errors.New("" +
"1. check the node name in the config-sample.yaml\n" +
"2. check the node name in the Kubernetes cluster\n" +
"3. only support to delete a worker\n")
}

f.PipelineCache.Set("dstNode", node)
Expand Down

0 comments on commit 27207af

Please sign in to comment.