fix: add alpha cmd before phase run cmds

This commit is contained in:
77yu77 2022-10-08 06:20:12 +00:00
parent b5bb4acbeb
commit 5b823a9e5e
8 changed files with 187 additions and 60 deletions

35
cmd/kk/cmd/alpha/alpha.go Normal file
View File

@ -0,0 +1,35 @@
/*
Copyright 2022 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package alpha
import (
"github.com/spf13/cobra"
)
// NewAlphaCmd create a new Alpha command
func NewAlphaCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "alpha",
Short: "Add alpha before the cmds to tag them for testing",
}
cmd.AddCommand(NewCmdCreate())
cmd.AddCommand(NewCmdUpgrade())
return cmd
}

View File

@ -0,0 +1,47 @@
/*
Copyright 2022 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package alpha
import (
"github.com/spf13/cobra"
"github.com/kubesphere/kubekey/cmd/kk/cmd/options"
"github.com/kubesphere/kubekey/cmd/kk/cmd/create/phase"
)
type CreateOptions struct {
CommonOptions *options.CommonOptions
}
func NewCreateOptions() *CreateOptions {
return &CreateOptions{
CommonOptions: options.NewCommonOptions(),
}
}
// NewCmdCreate creates a new create command
func NewCmdCreate() *cobra.Command {
o := NewCreateOptions()
cmd := &cobra.Command{
Use: "create",
Short: "Create a cluster by phase cmds for testing",
}
o.CommonOptions.AddCommonFlag(cmd)
cmd.AddCommand(phase.NewPhaseCommand())
return cmd
}

View File

@ -0,0 +1,46 @@
/*
Copyright 2022 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package alpha
import (
"github.com/kubesphere/kubekey/cmd/kk/cmd/upgrade/phase"
"github.com/kubesphere/kubekey/cmd/kk/cmd/options"
"github.com/spf13/cobra"
)
type UpgradeOptions struct {
CommonOptions *options.CommonOptions
}
func NewUpgradeOptions() *UpgradeOptions {
return &UpgradeOptions{
CommonOptions: options.NewCommonOptions(),
}
}
// NewCmdUpgrade creates a new upgrade command
func NewCmdUpgrade() *cobra.Command {
o := NewUpgradeOptions()
cmd := &cobra.Command{
Use: "upgrade",
Short: "Upgrade your cluster by phase cmd for testing",
}
o.CommonOptions.AddCommonFlag(cmd)
cmd.AddCommand(phase.NewPhaseCommand())
return cmd
}

View File

@ -19,7 +19,6 @@ package create
import (
"github.com/spf13/cobra"
"github.com/kubesphere/kubekey/cmd/kk/cmd/create/phase"
"github.com/kubesphere/kubekey/cmd/kk/cmd/options"
)
@ -46,6 +45,5 @@ func NewCmdCreate() *cobra.Command {
cmd.AddCommand(NewCmdCreateCluster())
cmd.AddCommand(NewCmdCreateConfig())
cmd.AddCommand(NewCmdCreateManifest())
cmd.AddCommand(phase.NewPhaseCommand())
return cmd
}

View File

@ -27,6 +27,7 @@ import (
"github.com/spf13/cobra"
"github.com/kubesphere/kubekey/cmd/kk/cmd/add"
"github.com/kubesphere/kubekey/cmd/kk/cmd/alpha"
"github.com/kubesphere/kubekey/cmd/kk/cmd/artifact"
"github.com/kubesphere/kubekey/cmd/kk/cmd/cert"
"github.com/kubesphere/kubekey/cmd/kk/cmd/completion"
@ -107,6 +108,8 @@ func NewKubeKeyCommand(o KubeKeyOptions) *cobra.Command {
cmds.AddCommand(initOs.NewCmdInit())
cmds.AddCommand(alpha.NewAlphaCmd())
cmds.AddCommand(create.NewCmdCreate())
cmds.AddCommand(delete.NewCmdDelete())
cmds.AddCommand(add.NewCmdAdd())

View File

@ -28,7 +28,6 @@ import (
"github.com/kubesphere/kubekey/cmd/kk/pkg/version/kubesphere"
"github.com/kubesphere/kubekey/cmd/kk/cmd/options"
"github.com/kubesphere/kubekey/cmd/kk/cmd/upgrade/phase"
"github.com/kubesphere/kubekey/cmd/kk/cmd/util"
)
@ -62,7 +61,6 @@ func NewCmdUpgrade() *cobra.Command {
}
o.CommonOptions.AddCommonFlag(cmd)
o.AddFlags(cmd)
cmd.AddCommand(phase.NewPhaseCommand())
if err := completionSetting(cmd); err != nil {
panic(fmt.Sprintf("Got error with the completion setting"))

View File

@ -1,5 +1,5 @@
# NAME
**kk create phase**: Create your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
**kk alpha create phase**: Create your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
# DESCRIPTION
Create your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
@ -8,13 +8,13 @@ Create your cluster in phases to a newer version with this command, which is no
| Command | Description |
| - | - |
| kk create phase binary | Download the binaries on the local. |
| kk create phase os | Init the os configure. |
| kk create phase images | Down the container and pull the images before creating your cluster. |
| kk create phase etcd | Install the etcd on the master. |
| kk create phase join | Join the control-plane nodes and worker nodes in the k8s cluster. |
| kk create phase configure | Configure the k8s cluster with plugins, certs and PV. |
| kk create phase kubesphere | Install the kubesphere with the input version. |
| kk alpha create phase binary | Download the binaries on the local. |
| kk alpha create phase os | Init the os configure. |
| kk alpha create phase images | Down the container and pull the images before creating your cluster. |
| kk alpha create phase etcd | Install the etcd on the master. |
| kk alpha create phase join | Join the control-plane nodes and worker nodes in the k8s cluster. |
| kk alpha create phase configure | Configure the k8s cluster with plugins, certs and PV. |
| kk alpha create phase kubesphere | Install the kubesphere with the input version. |
# OPTIONS
@ -67,97 +67,97 @@ Skip confirm check. The default is `false`.
## Create an `all-in-one` pure Kubernetes cluster with default version
Download the binarys of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase binary
$ kk alpha create phase binary
```
Init the configure os of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase os
$ kk alpha create phase os
```
Pull the images of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase images
$ kk alpha create phase images
```
Install the etcd of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase etcd
$ kk alpha create phase etcd
```
Init the k8s cluster of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase init
$ kk alpha create phase init
```
Join the nodes to the k8s cluster of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase join
$ kk alpha create phase join
```
Configure the k8s cluster of creating an `all-in-one` Kubernetes cluster from a default version.
```
$ kk create phase configure
$ kk alpha create phase configure
```
## Create an `all-in-one` pure Kubernetes cluster with specified version
Download the binarys of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase binary --with-kubernetes v1.22.0
$ kk alpha create phase binary --with-kubernetes v1.22.0
```
Init the configure os of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase os
$ kk alpha create phase os
```
Pull the images of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase images --with-kubernetes v1.22.0
$ kk alpha create phase images --with-kubernetes v1.22.0
```
Install the etcd of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase etcd
$ kk alpha create phase etcd
```
Init the k8s cluster of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase init --with-kubernetes v1.22.0
$ kk alpha create phase init --with-kubernetes v1.22.0
```
Join the nodes to the k8s cluster of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase join --with-kubernetes v1.22.0
$ kk alpha create phase join --with-kubernetes v1.22.0
```
Configure the k8s cluster of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase configure --with-kubernetes v1.22.0
$ kk alpha create phase configure --with-kubernetes v1.22.0
```
Install the k8s cluster of creating an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk create phase kubesphere --with-kubesphere v3.3.0
$ kk alpha create phase kubesphere --with-kubesphere v3.3.0
```
## Create a kubernetes cluster from a specified configuration file
Download the binarys of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase binary -f config-sample.yaml
$ kk alpha create phase binary -f config-sample.yaml
```
Init the configure os of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase os
$ kk alpha create phase os
```
Pull the images of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase images -f config-sample.yaml
$ kk alpha create phase images -f config-sample.yaml
```
Install the etcd of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase etcd -f config-sample.yaml
$ kk alpha create phase etcd -f config-sample.yaml
```
Init the k8s cluster of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase init -f config-sample.yaml
$ kk alpha create phase init -f config-sample.yaml
```
Join the nodes to the k8s cluster of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase join -f config-sample.yaml
$ kk alpha create phase join -f config-sample.yaml
```
Configure the k8s cluster of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase configure -f config-sample.yaml
$ kk alpha create phase configure -f config-sample.yaml
```
Install the k8s cluster of creating a kubernetes cluster from a specified configuration file.
```
$ kk create phase kubesphere -f config-sample.yaml
$ kk alpha create phase kubesphere -f config-sample.yaml
```
## Create a cluster from the specified configuration file and use the artifact to install operating system packages.
import a KubeKey artifact named `my-artifact.tar.gz`.
@ -166,33 +166,33 @@ $ kk artifact import -a my-artifact.tar.gz --with-packages
```
Download the binarys of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase binary -f config-sample.yaml
$ kk alpha create phase binary -f config-sample.yaml
```
Init the configure os of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase os
$ kk alpha create phase os
```
Pull the images of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase images -f config-sample.yaml
$ kk alpha create phase images -f config-sample.yaml
```
Install the etcd of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase etcd -f config-sample.yaml
$ kk alpha create phase etcd -f config-sample.yaml
```
Init the k8s cluster of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase init -f config-sample.yaml
$ kk alpha create phase init -f config-sample.yaml
```
Join the nodes to the k8s cluster of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase join -f config-sample.yaml
$ kk alpha create phase join -f config-sample.yaml
```
Configure the k8s cluster of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase configure -f config-sample.yaml
$ kk alpha create phase configure -f config-sample.yaml
```
Install the k8s cluster of creating a cluster from the specified configuration file and use the artifact to install operating system packages.
```
$ kk create phase kubesphere -f config-sample.yaml
$ kk alpha create phase kubesphere -f config-sample.yaml
```

View File

@ -1,5 +1,5 @@
# NAME
**kk upgade phase**: Upgrade your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
**kk alpha upgade phase**: Upgrade your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
# DESCRIPTION
Upgrade your cluster in phases to a newer version with this command, which is not enough and need to add phase cmds.
@ -8,10 +8,10 @@ Upgrade your cluster in phases to a newer version with this command, which is n
| Command | Description |
| - | - |
| kk upgrade phase binary | Download the binary and synchronize kubernetes binaries. |
| kk upgrade phase images | Pull the images before create your cluster. |
| kk upgrade phase nodes | Upgrade cluster on master nodes and worker nodes to the version you input. |
| kk upgrade phase kubesphere | Upgrade your kubesphere to a newer version with this command. |
| kk alpha upgrade phase binary | Download the binary and synchronize kubernetes binaries. |
| kk alpha upgrade phase images | Pull the images before create your cluster. |
| kk alpha upgrade phase nodes | Upgrade cluster on master nodes and worker nodes to the version you input. |
| kk alpha upgrade phase kubesphere | Upgrade your kubesphere to a newer version with this command. |
# OPTIONS
@ -46,36 +46,36 @@ Skip confirm check. The default is `false`.
## Upgrade an `all-in-one` Kubernetes cluster from a specified version
Upgrade the binarys of an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk upgrade phase binary --with-kubernetes v1.23.8
$ kk alpha upgrade phase binary --with-kubernetes v1.23.8
```
Upgrade the images of an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk upgrade phase images --with-kubernetes v1.23.8
$ kk alpha upgrade phase images --with-kubernetes v1.23.8
```
Upgrade the cluster nodes of an `all-in-one` Kubernetes cluster from a specified version.
```
$ kk upgrade phase nodes --with-kubernetes v1.23.8
$ kk alpha upgrade phase nodes --with-kubernetes v1.23.8
```
Upgrade the kubesphere of an `all-in-one` Kubernetes cluster from a specified version if you need.
```
$ kk upgrade phase kubesphere --with-kubesphere v3.3.0
$ kk alpha upgrade phase kubesphere --with-kubesphere v3.3.0
```
## Upgrade an kubernetes cluster from a specified configuration file
Upgrade the binarys from a specified configuration file.
```
$ kk upgrade phase binary -f config-example.yaml
$ kk alpha upgrade phase binary -f config-example.yaml
```
Upgrade the images from a specified configuration file.
```
$ kk upgrade phase images -f config-example.yaml
$ kk alpha upgrade phase images -f config-example.yaml
```
Upgrade the cluster nodes from a specified configuration file.
```
$ kk upgrade phase nodes -f config-example.yaml
$ kk alpha upgrade phase nodes -f config-example.yaml
```
Upgrade the kubesphere from a specified configuration file if you need.
```
$ kk upgrade phase kubesphere -f config-example.yaml
$ kk alpha upgrade phase kubesphere -f config-example.yaml
```
## Upgrade a cluster using a KubeKey artifact (in an offline enviroment).
import a KubeKey artifact named `my-artifact.tar.gz`.
@ -84,17 +84,17 @@ $ kk artifact import -a my-artifact.tar.gz
```
Upgrade the binarys from a specified configuration file.
```
$ kk upgrade phase binary -f config-example.yaml
$ kk alpha upgrade phase binary -f config-example.yaml
```
Upgrade the images from a specified configuration file.
```
$ kk upgrade phase images -f config-example.yaml
$ kk alpha upgrade phase images -f config-example.yaml
```
Upgrade the cluster nodes from a specified configuration file.
```
$ kk upgrade phase nodes -f config-example.yaml
$ kk alpha upgrade phase nodes -f config-example.yaml
```
Upgrade the kubesphere from a specified configuration file if you need.
```
$ kk upgrade phase kubesphere -f config-example.yaml
$ kk alpha upgrade phase kubesphere -f config-example.yaml
```