Skip to content

Commit

Permalink
Merge pull request #1540 from 77yu77/fix/add_alpha_phase_cmd
Browse files Browse the repository at this point in the history
fix: add alpha cmd before phase run cmds
  • Loading branch information
ks-ci-bot authored Nov 11, 2022
2 parents 3e5026c + 5b823a9 commit 2b57164
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 60 deletions.
35 changes: 35 additions & 0 deletions cmd/kk/cmd/alpha/alpha.go
Original file line number Diff line number Diff line change
@@ -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
}
47 changes: 47 additions & 0 deletions cmd/kk/cmd/alpha/create.go
Original file line number Diff line number Diff line change
@@ -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
}
46 changes: 46 additions & 0 deletions cmd/kk/cmd/alpha/upgrade.go
Original file line number Diff line number Diff line change
@@ -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
}

2 changes: 0 additions & 2 deletions cmd/kk/cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -46,6 +45,5 @@ func NewCmdCreate() *cobra.Command {
cmd.AddCommand(NewCmdCreateCluster())
cmd.AddCommand(NewCmdCreateConfig())
cmd.AddCommand(NewCmdCreateManifest())
cmd.AddCommand(phase.NewPhaseCommand())
return cmd
}
3 changes: 3 additions & 0 deletions cmd/kk/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 0 additions & 2 deletions cmd/kk/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"))
Expand Down
78 changes: 39 additions & 39 deletions docs/commands/kk-create-phase.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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`.
Expand All @@ -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
```
Loading

0 comments on commit 2b57164

Please sign in to comment.