Skip to content

Commit

Permalink
Merge pull request #82 from cuisongliu/bugfix/send_package
Browse files Browse the repository at this point in the history
Bugfix/send package
  • Loading branch information
fanux authored Aug 14, 2019
2 parents 7f0d095 + 7af1110 commit 0d5a381
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
17 changes: 12 additions & 5 deletions install/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"github.com/wonderivan/logger"
"strings"
"text/template"
)

Expand Down Expand Up @@ -34,19 +35,25 @@ var ConfigType string
func Config() {
switch ConfigType {
case "kubeadm":
kubeadmConfig()
printlnKubeadmConfig()
default:
kubeadmConfig()
printlnKubeadmConfig()
}
}

func kubeadmConfig() {
fmt.Print(TemplateText)
func kubeadmConfig() string {
var sb strings.Builder
sb.Write([]byte(TemplateText))
return sb.String()
}

func printlnKubeadmConfig() {
fmt.Println(kubeadmConfig())
}

//Template is
func Template(masters []string, vip string, version string) []byte {
return TemplateFromTemplateContent(masters, vip, version, TemplateText)
return TemplateFromTemplateContent(masters, vip, version, kubeadmConfig())
}

func TemplateFromTemplateContent(masters []string, vip, version, templateContent string) []byte {
Expand Down
12 changes: 8 additions & 4 deletions install/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ func BuildInit(masters []string, nodes []string, vip, pkgUrl string) {
i.Print("SendPackage", "KubeadmConfigInstall")
i.InstallMaster0()
i.Print("SendPackage", "KubeadmConfigInstall", "InstallMaster0")
i.JoinMasters()
i.Print("SendPackage", "KubeadmConfigInstall", "InstallMaster0", "JoinMasters")
i.JoinNodes()
i.Print("SendPackage", "KubeadmConfigInstall", "InstallMaster0", "JoinMasters", "JoinNodes")
if len(i.Masters) > 1 {
i.JoinMasters()
i.Print("SendPackage", "KubeadmConfigInstall", "InstallMaster0", "JoinMasters")
}
if len(i.Nodes) > 0 {
i.JoinNodes()
i.Print("SendPackage", "KubeadmConfigInstall", "InstallMaster0", "JoinMasters", "JoinNodes")
}
}

//KubeadmConfigInstall is
Expand Down
2 changes: 1 addition & 1 deletion install/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func SendPackage(url string, hosts []string) {
var wm sync.WaitGroup
for _, host := range hosts {
wm.Add(1)
go func(master string) {
go func(host string) {
defer wm.Done()
logger.Debug("please wait for tar zxvf exec")
if RemoteFilExist(host, kubeLocal) {
Expand Down

0 comments on commit 0d5a381

Please sign in to comment.