update add nodes

Signed-off-by: “Forest-L <lilin@yunify.com>
This commit is contained in:
“Forest-L 2020-08-24 10:45:07 +08:00
parent 7b6064614b
commit 01828bd2b9
7 changed files with 32 additions and 19 deletions

View File

@ -173,7 +173,7 @@ You can enable any of them according to your demands. It is highly recommended t
Add new node's information to the cluster config file, then apply the changes.
```shell script
./kk scale -f config-sample.yaml
./kk add nodes -f config-sample.yaml
```
### Delete Nodes

View File

@ -173,7 +173,7 @@ KubeSphere 有多个可插拔功能组件,功能组件的介绍可参考 [配
将新节点的信息添加到群集配置文件,然后应用更改。
```shell script
./kk scale -f config-sample.yaml
./kk add nodes -f config-sample.yaml
```
### 删除节点

13
cmd/add.go Normal file
View File

@ -0,0 +1,13 @@
package cmd
import "github.com/spf13/cobra"
// addCmd represents the add command
var addCmd = &cobra.Command{
Use: "add",
Short: "Add nodes to kubernetes cluster",
}
func init() {
rootCmd.AddCommand(addCmd)
}

View File

@ -16,24 +16,24 @@ limitations under the License.
package cmd
import (
"github.com/kubesphere/kubekey/pkg/scale"
"github.com/kubesphere/kubekey/pkg/add"
"github.com/kubesphere/kubekey/pkg/util"
"github.com/spf13/cobra"
)
// scaleCmd represents the scale command
var scaleCmd = &cobra.Command{
Use: "scale",
Short: "Scale a cluster according to the new nodes information from the specified configuration file",
// addNodeCmd represents the nodes command
var addNodesCmd = &cobra.Command{
Use: "nodes",
Short: "Add a cluster according to the new nodes information from the specified configuration file",
RunE: func(cmd *cobra.Command, args []string) error {
logger := util.InitLogger(opt.Verbose)
return scale.ScaleCluster(opt.ClusterCfgFile, "", "", logger, false, opt.Verbose, opt.SkipCheck, opt.SkipPullImages)
return add.AddNodes(opt.ClusterCfgFile, "", "", logger, false, opt.Verbose, opt.SkipCheck, opt.SkipPullImages)
},
}
func init() {
rootCmd.AddCommand(scaleCmd)
scaleCmd.Flags().StringVarP(&opt.ClusterCfgFile, "file", "f", "", "Path to a configuration file")
scaleCmd.Flags().BoolVarP(&opt.SkipCheck, "yes", "y", false, "Skip pre-check of the installation")
scaleCmd.Flags().BoolVarP(&opt.SkipPullImages, "skip-pull-images", "", false, "Skip pre pull images")
addCmd.AddCommand(addNodesCmd)
addNodesCmd.Flags().StringVarP(&opt.ClusterCfgFile, "file", "f", "", "Path to a configuration file")
addNodesCmd.Flags().BoolVarP(&opt.SkipCheck, "yes", "y", false, "Skip pre-check of the installation")
addNodesCmd.Flags().BoolVarP(&opt.SkipPullImages, "skip-pull-images", "", false, "Skip pre pull images")
}

View File

@ -24,7 +24,7 @@ import (
var shortVersion bool
// versionCmd represents the scale command
// versionCmd represents the add command
var versionCmd = &cobra.Command{
Use: "version",
Short: "print the client version information",

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scale
package add
import (
"fmt"
@ -32,7 +32,7 @@ import (
"path/filepath"
)
func ScaleCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Logger, ksEnabled, verbose, skipCheck, skipPullImages bool) error {
func AddNodes(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Logger, ksEnabled, verbose, skipCheck, skipPullImages bool) error {
currentDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
return errors.Wrap(err, "Faild to get current dir")
@ -50,7 +50,7 @@ func ScaleCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Logg
}
func ExecTasks(mgr *manager.Manager) error {
scaleTasks := []manager.Task{
addNodeTasks := []manager.Task{
{Task: preinstall.Precheck, ErrMsg: "Failed to precheck"},
{Task: preinstall.DownloadBinaries, ErrMsg: "Failed to download kube binaries"},
{Task: preinstall.InitOS, ErrMsg: "Failed to init OS"},
@ -66,7 +66,7 @@ func ExecTasks(mgr *manager.Manager) error {
{Task: kubernetes.JoinNodesToCluster, ErrMsg: "Failed to join node"},
}
for _, step := range scaleTasks {
for _, step := range addNodeTasks {
if err := step.Run(mgr); err != nil {
return errors.Wrap(err, step.ErrMsg)
}

View File

@ -48,7 +48,7 @@ func UpgradeCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Lo
}
func ExecTasks(mgr *manager.Manager) error {
scaleTasks := []manager.Task{
upgradeTasks := []manager.Task{
{Task: GetClusterInfo, ErrMsg: "Failed to get cluster info"},
{Task: GetCurrentVersions, ErrMsg: "Failed to get current version"},
{Task: preinstall.InitOS, ErrMsg: "Failed to download kube binaries"},
@ -58,7 +58,7 @@ func ExecTasks(mgr *manager.Manager) error {
{Task: kubesphere.DeployKubeSphere, ErrMsg: "Failed to upgrade kubesphere"},
}
for _, step := range scaleTasks {
for _, step := range upgradeTasks {
if err := step.Run(mgr); err != nil {
return errors.Wrap(err, step.ErrMsg)
}