mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: --container-manager flag doesn't work
Signed-off-by: Leo Li <jacksama@foxmail.com>
This commit is contained in:
parent
2fb0649193
commit
288efcca28
|
|
@ -55,6 +55,7 @@ func NewCmdCreateCluster() *cobra.Command {
|
|||
Short: "Create a Kubernetes or KubeSphere cluster",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
util.CheckErr(o.Complete(cmd, args))
|
||||
util.CheckErr(o.Validate(cmd, args))
|
||||
util.CheckErr(o.Run())
|
||||
},
|
||||
}
|
||||
|
|
@ -78,6 +79,15 @@ func (o *CreateClusterOptions) Complete(cmd *cobra.Command, args []string) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (o *CreateClusterOptions) Validate(cmd *cobra.Command, args []string) error {
|
||||
switch o.ContainerManager {
|
||||
case common.Docker, common.Conatinerd, common.Crio, common.Isula:
|
||||
default:
|
||||
return fmt.Errorf("unsupport container runtime [%s]", o.ContainerManager)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *CreateClusterOptions) Run() error {
|
||||
arg := common.Argument{
|
||||
FilePath: o.ClusterCfgFile,
|
||||
|
|
|
|||
|
|
@ -65,9 +65,6 @@ func NewKubeRuntime(flag string, arg Argument) (*KubeRuntime, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if arg.ContainerManager != Docker && arg.ContainerManager != "" {
|
||||
defaultCluster.Kubernetes.ContainerManager = arg.ContainerManager
|
||||
}
|
||||
|
||||
base := connector.NewBaseRuntime(cluster.Name, connector.NewDialer(), arg.Debug, arg.IgnoreErr)
|
||||
for _, v := range hostGroups.All {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ func NewLoader(flag string, arg Argument) Loader {
|
|||
}
|
||||
|
||||
type DefaultLoader struct {
|
||||
arg Argument
|
||||
KubernetesVersion string
|
||||
KubeSphereVersion string
|
||||
KubeSphereEnable bool
|
||||
|
|
@ -62,6 +63,7 @@ type DefaultLoader struct {
|
|||
|
||||
func NewDefaultLoader(arg Argument) *DefaultLoader {
|
||||
return &DefaultLoader{
|
||||
arg: arg,
|
||||
KubernetesVersion: arg.KubernetesVersion,
|
||||
KubeSphereVersion: arg.KsVersion,
|
||||
KubeSphereEnable: arg.KsEnable,
|
||||
|
|
@ -127,13 +129,17 @@ func (d *DefaultLoader) Load() (*kubekeyapiv1alpha2.Cluster, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if d.arg.ContainerManager != "" && d.arg.ContainerManager != Docker {
|
||||
allInOne.Spec.Kubernetes.ContainerManager = d.arg.ContainerManager
|
||||
}
|
||||
|
||||
// must be a lower case
|
||||
allInOne.Name = "kubekey" + time.Now().Format("2006-01-02")
|
||||
|
||||
return &allInOne, nil
|
||||
}
|
||||
|
||||
type FileLoader struct {
|
||||
arg Argument
|
||||
FilePath string
|
||||
KubernetesVersion string
|
||||
KubeSphereVersion string
|
||||
|
|
@ -142,6 +148,7 @@ type FileLoader struct {
|
|||
|
||||
func NewFileLoader(arg Argument) *FileLoader {
|
||||
return &FileLoader{
|
||||
arg: arg,
|
||||
FilePath: arg.FilePath,
|
||||
KubernetesVersion: arg.KubernetesVersion,
|
||||
KubeSphereVersion: arg.KsVersion,
|
||||
|
|
@ -236,6 +243,10 @@ func (f FileLoader) Load() (*kubekeyapiv1alpha2.Cluster, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if f.arg.ContainerManager != "" && f.arg.ContainerManager != Docker {
|
||||
clusterCfg.Spec.Kubernetes.ContainerManager = f.arg.ContainerManager
|
||||
}
|
||||
|
||||
clusterCfg.Name = objName
|
||||
return &clusterCfg, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue