Skip to content

Commit 4c55cda

Browse files
committed
improvement: update k8s install
1 parent 7718d62 commit 4c55cda

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

install/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package install
66
import (
77
"bytes"
88
"github.com/cuisongliu/sshcmd/pkg/sshutil"
9-
"strings"
109
"text/template"
1110
)
1211

@@ -32,6 +31,7 @@ type InstallConfig struct {
3231
ExtendNfsAddr string
3332
NfsPath string
3433
DefaultSc string
34+
Master0 string
3535
}
3636

3737
func (i *InstallConfig) Template(tpl string) string {
@@ -41,7 +41,7 @@ func (i *InstallConfig) Template(tpl string) string {
4141
i.DefaultSc = "nfs-data"
4242
}
4343
if len(i.ExtendNfsAddr) == 0 {
44-
i.ExtendNfsAddr = strings.Split(i.Masters, "-")[0]
44+
i.ExtendNfsAddr = i.Master0
4545
}
4646

4747
t := template.Must(template.New("code").Parse(tpl))

install/k8s.go

+12-17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func K8sInstall() {
1919
ExtendNfsAddr: ExtendNfsAddr,
2020
NfsPath: NfsPath,
2121
DefaultSc: DefaultSc,
22+
Master0: strings.Split(Masters, "-")[0],
2223
}
2324
i.K8sInstall()
2425
if i.EnableIngress {
@@ -38,38 +39,32 @@ func (i *InstallConfig) K8sInstall() {
3839
} else {
3940
k8scmd = fmt.Sprintf("docker run -v /root:/root -v /etc/kubernetes:/etc/kubernetes --rm -e MASTER_IP=%s -e NODE_IP=%s -e PASS=%s ysicing/k7s", Masters, Wokers, SSHConfig.Password)
4041
}
41-
ip := strings.Split(i.Masters, "-")[0]
42-
SSHConfig.Cmd(ip, k8scmd)
43-
SSHConfig.Cmd(ip, "kubectl taint nodes --all node-role.kubernetes.io/master-") // 允许master节点调度
44-
SSHConfig.Cmd(ip, "helminit")
42+
43+
SSHConfig.Cmd(i.Master0, k8scmd)
44+
SSHConfig.Cmd(i.Master0, "kubectl taint nodes --all node-role.kubernetes.io/master- || sleep 1") // 允许master节点调度
45+
SSHConfig.Cmd(i.Master0, "helminit")
4546

4647
}
4748

4849
func (i *InstallConfig) IngressInstall() {
4950
ncingcmd := fmt.Sprintf(`echo '%s' | kubectl apply -f -`, NcIngress)
50-
SSHConfig.Cmd(strings.Split(i.Masters, "-")[0], ncingcmd)
51+
SSHConfig.Cmd(i.Master0, ncingcmd)
5152
}
5253

5354
func (i *InstallConfig) NfsInstall() {
54-
// TODO
55-
if i.Hosts[0] == i.ExtendNfsAddr || len(i.ExtendNfsAddr) == 0 {
56-
// ip := i.Hosts[0]
57-
ip := strings.Split(i.Masters, "-")[0]
58-
klog.Info("install nfs on ", ip)
55+
if i.Master0 == i.ExtendNfsAddr || len(i.ExtendNfsAddr) == 0 {
56+
klog.Info("install nfs on ", i.Master0)
5957
nfsinstallprecmd := fmt.Sprintf(`echo '%s' > /tmp/nfs.install`, i.Template(installnfs))
60-
SSHConfig.Cmd(ip, nfsinstallprecmd)
58+
SSHConfig.Cmd(i.Master0, nfsinstallprecmd)
6159
nfsinstallcmd := fmt.Sprintf("bash -x /tmp/nfs.install")
62-
SSHConfig.Cmd(ip, nfsinstallcmd)
60+
SSHConfig.Cmd(i.Master0, nfsinstallcmd)
6361
}
6462
}
6563

6664
func (i *InstallConfig) NfsDeploy() {
67-
// TODO
68-
// ip := i.Hosts[0]
69-
ip := strings.Split(i.Masters, "-")[0]
70-
klog.Info("deploy nfs to k8s ", ip)
65+
klog.Info("deploy nfs to k8s ", i.Master0)
7166
scingcmd := fmt.Sprintf(`echo '%s' | kubectl apply -f -`, i.Template(ScDefault))
72-
SSHConfig.Cmd(i.Hosts[0], scingcmd)
67+
SSHConfig.Cmd(i.Master0, scingcmd)
7368
}
7469

7570
const installnfs = `

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.2
1+
0.6.3

0 commit comments

Comments
 (0)