-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrite install and delete for app #428
Conversation
34c3940
to
4dc644d
Compare
pkg/appmanager/appmanager.go
Outdated
go func(node string) { | ||
defer wg.Done() | ||
// DELETE images | ||
for _, cmd := range r.Cmd { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup这地方仅关心清理tar包和安装目录即可。 config里的指令一律在Run接口里去实现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok~
pkg/appmanager/appmanager.go
Outdated
workspace := fmt.Sprintf("%s/%s", p.Workdir, p.Name) | ||
install.SendPackage(p.URL, []string{host}, workspace, nil, nil) | ||
func send(host string, p *PkgConfig) { | ||
if p.ValuesContent == "-" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我这里本来的想法是ValuesContent里就是真实的values文件的内容了。 -f 可能没有指定 或者是标准输入 或者是个指定的文件,那么在前期处理时我们就可以先读到ValuesContent里,在send时就可以统一处理了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文件转成 待读取的 string.
io 转成 string , 是这个意思吧~
我明白了. send统一处理.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们只把valuesContent拷贝到包的目录进行覆盖什么的 不关心kubectl, 用户在自己的指令里去关心怎么使用这个values
pkg/appmanager/appmanager.go
Outdated
workspace := fmt.Sprintf("%s/%s", p.Workdir, p.Name) | ||
install.SendPackage(p.URL, []string{host}, workspace, nil, nil) | ||
func send(host string, p *PkgConfig) { | ||
if p.ValuesContent == "-" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们只把valuesContent拷贝到包的目录进行覆盖什么的 不关心kubectl, 用户在自己的指令里去关心怎么使用这个values
pkg/appmanager/appmanager.go
Outdated
} | ||
} | ||
|
||
func (r *RunOnMaster) CleanUp(config install.SealConfig, p *PkgConfig) { | ||
//TODO | ||
// kubectl delete -f values.yaml | ||
for _, cmd := range r.Cmd { | ||
CmdWorkSpace(config.Masters[0], cmd.Cmd, p.Workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RunOnMaster 如果每个节点都清理了. master就不用重复清理. ~
pkg/appmanager/deleteapp.go
Outdated
pkgConfig.Workspace = fmt.Sprintf("%s/%s", flag.WorkDir, pkgConfig.Name) | ||
|
||
everyNodesCmd, masterOnlyCmd := NewDeleteCommands(pkgConfig.Cmds) | ||
masterOnlyCmd.CleanUp(*c, pkgConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
依然去调用Run命令
pkg/appmanager/installapp.go
Outdated
|
||
pkgConfig.Workdir = flag.WorkDir | ||
pkgConfig.Workspace = fmt.Sprintf("%s/%s", flag.WorkDir, pkgConfig.Name) | ||
s, err := ReadStdin(flag.Values, flag.WorkDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对 这里做个统一的预处理,最好写成一个函数,不管是啥先读到valuesContent中去
测试脚本不错~ |
pkg/appmanager/appmanager.go
Outdated
|
||
// 默认为空值, 如果ValuesContent有值, 说明使用了file或者-, 将valuesContent写入 workspace/vaules.yml | ||
if p.ValuesContent != "" { | ||
_ = ReadStringToFile(p.ValuesContent, p.Workspace+"/values.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可能需要考虑一下远程的情况?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样么. 生成的文件复制到master[0]上
if p.ValuesContent != "" {
_ = ReadStringToFile(p.ValuesContent, "/tmp/values.yaml")
install.SendPackage("/tmp/values.yaml", config.Masters[:1], p.Workspace,nil,nil )
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhangguanzhang 你不是写了个从内存字符串直接到远程文件的函数?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不是我写的吧,我之前是准备sftp的client写个,结果看代码里有类似的方法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那我记错了 我记得我当初审核代码时见过 现在找不到了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额. 这个实现得想一想 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重写delete 和install。
测试环境 test/testforlocal.sh.
stdin写入的位置转移之 appmanager,
cloud.go的依赖函数CmdWorkSpace。