diff --git a/scheduler/image/cobra2.jpg b/scheduler/image/cobra2.jpg deleted file mode 100644 index f484a08..0000000 Binary files a/scheduler/image/cobra2.jpg and /dev/null differ diff --git a/scheduler/image/cobra3.jpg b/scheduler/image/cobra3.jpg deleted file mode 100644 index ea705b6..0000000 Binary files a/scheduler/image/cobra3.jpg and /dev/null differ diff --git a/scheduler/image/cobra4.jpg b/scheduler/image/cobra4.jpg deleted file mode 100644 index 5255eb9..0000000 Binary files a/scheduler/image/cobra4.jpg and /dev/null differ diff --git a/scheduler/image/cobra5.jpg b/scheduler/image/cobra5.jpg deleted file mode 100644 index 806bf37..0000000 Binary files a/scheduler/image/cobra5.jpg and /dev/null differ diff --git a/scheduler/image/cobra6.jpg b/scheduler/image/cobra6.jpg deleted file mode 100644 index 1b2bbaa..0000000 Binary files a/scheduler/image/cobra6.jpg and /dev/null differ diff --git a/scheduler/调度器初始化启动.md b/scheduler/调度器初始化启动.md deleted file mode 100644 index 3704058..0000000 --- a/scheduler/调度器初始化启动.md +++ /dev/null @@ -1,74 +0,0 @@ -# 调度器启动 - -## 前言 -本篇介绍scheduler的初始化相关逻辑 - -## 入口 -入口函数是位于`cmd/kube-scheduler/scheduler.go`中的main()方法,调用的是app.NewSchedulerCommand()方法,跳转至此方法,可以看到函数上方的注释: - -``` -// NewSchedulerCommand creates a *cobra.Command object with default parameters -func NewSchedulerCommand() *cobra.Command { - ... -} -``` -NewSchedulerCommand创建的是一个cobra.Command对象,后续的命令行处理相关功能都是借助cobra来实现的,那么继续往下之前,为了避免一脸懵,有必要了解一下cobra这个工具 - -## cobra -#### 什么是cobra? -github主页: https://github.com/spf13/cobra -主页的介绍是: Cobra是一个强大的用于创建现代化CLI命令行程序的库,用于生成应用程序和命令文件。众多高知名度的项目采用了它,例如我们熟悉的kubernetes和docker -cobra创建的程序CLI遵循的模式是: `APPNAME COMMAND ARG --FLAG`,与常见的其他命令行程序一样,例如git: `git clone URL --bare` - -#### 安装: - -``` -#最简单的安装方式,但毫无意外,事情并没有那么简单,我们的网络的问题,导致无法正常安装依赖, -go get -u github.com/spf13/cobra/cobra - -#怎么办呢?先进入GOPATH中,手动安装报错缺失的两个依赖: -cd /Users/ywq/go/ -mkdir -p src/golang.org/x -cd golang.org/x -git clone https://github.com/golang/text.git -git clone https://github.com/golang/sys.git - -#然后执行: -go install github.com/spf13/cobra/cobra -matebook-x-pro:x ywq$ ls /Users/ywq/go/bin/cobra -/Users/ywq/go/bin/cobra -#安装完毕,记得把GOBIN加入PATH环境变量哦,否则无法直接运行cobra命令 -``` - -#### 简单试用cobra: -``` -matebook-x-pro:local ywq$ cd /Users/ywq/go/src/local/ -matebook-x-pro:local ywq$ cobra init testapp --pkg-name=local/testapp -matebook-x-pro:local ywq$ ls -testapp -matebook-x-pro:local ywq$ ls testapp/ -LICENSE cmd/ main.go -matebook-x-pro:local ywq$ ls testapp/cmd/ -root.go -matebook-x-pro:local ywq$ cd testapp -matebook-x-pro:local ywq$ go run main.go -# 报错:subcommand is required,要求提供子命令 - -# 现在还未创建子命令,那么来创建几个试试: -matebook-x-pro:testapp ywq$ cobra add get -get created at /Users/ywq/go/src/local/testapp -matebook-x-pro:testapp ywq$ cobra add delete -delete created at /Users/ywq/go/src/local/testapp -matebook-x-pro:testapp ywq$ cobra add add -add created at /Users/ywq/go/src/local/testapp -matebook-x-pro:testapp ywq$ cobra add update -matebook-x-pro:testapp ywq$ ls cmd/ -add.go delete.go get.go root.go update.go - -# 创建完成,会发现cmd/目录下多了几个go文件,调用试试: -matebook-x-pro:testapp ywq$ go run main.go get -get called -matebook-x-pro:testapp ywq$ go run main.go add -add called -``` -