diff --git a/data/config/language.txt b/data/config/language.txt
index 2c4c454..99fd52c 100644
--- a/data/config/language.txt
+++ b/data/config/language.txt
@@ -1 +1 @@
-en
\ No newline at end of file
+cn
\ No newline at end of file
diff --git a/data/config/tools.txt b/data/config/tools.txt
new file mode 100644
index 0000000..969966c
--- /dev/null
+++ b/data/config/tools.txt
@@ -0,0 +1 @@
+on,on,on
\ No newline at end of file
diff --git a/data/msg/msg.txt b/data/msg/msg.txt
index 6fb66a5..12a6f48 100644
--- a/data/msg/msg.txt
+++ b/data/msg/msg.txt
@@ -4,3 +4,5 @@
+
+
diff --git a/data/statistics/cpuinfo.txt b/data/statistics/cpuinfo.txt
index 56a6051..c227083 100644
--- a/data/statistics/cpuinfo.txt
+++ b/data/statistics/cpuinfo.txt
@@ -1 +1 @@
-1
\ No newline at end of file
+0
\ No newline at end of file
diff --git a/data/statistics/diskinfo.txt b/data/statistics/diskinfo.txt
index b393560..c24b6ae 100644
--- a/data/statistics/diskinfo.txt
+++ b/data/statistics/diskinfo.txt
@@ -1 +1 @@
-23
\ No newline at end of file
+38
\ No newline at end of file
diff --git a/data/statistics/k8snum.txt b/data/statistics/k8snum.txt
index c227083..56a6051 100644
--- a/data/statistics/k8snum.txt
+++ b/data/statistics/k8snum.txt
@@ -1 +1 @@
-0
\ No newline at end of file
+1
\ No newline at end of file
diff --git a/data/statistics/labellist.txt b/data/statistics/labellist.txt
index ffb9121..833ea6e 100644
--- a/data/statistics/labellist.txt
+++ b/data/statistics/labellist.txt
@@ -1 +1 @@
-,,,,
\ No newline at end of file
+,,,,k8s-test-001
\ No newline at end of file
diff --git a/data/statistics/meminfo.txt b/data/statistics/meminfo.txt
index bf0d87a..62f9457 100644
--- a/data/statistics/meminfo.txt
+++ b/data/statistics/meminfo.txt
@@ -1 +1 @@
-4
\ No newline at end of file
+6
\ No newline at end of file
diff --git a/data/statistics/nodenumlist.txt b/data/statistics/nodenumlist.txt
index ffb9121..8e3bb0e 100644
--- a/data/statistics/nodenumlist.txt
+++ b/data/statistics/nodenumlist.txt
@@ -1 +1 @@
-,,,,
\ No newline at end of file
+,,,,3
\ No newline at end of file
diff --git a/data/statistics/stuok.txt b/data/statistics/stuok.txt
index 9efc394..af84432 100644
--- a/data/statistics/stuok.txt
+++ b/data/statistics/stuok.txt
@@ -1 +1 @@
-0E+00
\ No newline at end of file
+1E+02
\ No newline at end of file
diff --git a/data/statistics/stuunkonw.txt b/data/statistics/stuunkonw.txt
index af84432..9efc394 100644
--- a/data/statistics/stuunkonw.txt
+++ b/data/statistics/stuunkonw.txt
@@ -1 +1 @@
-1E+02
\ No newline at end of file
+0E+00
\ No newline at end of file
diff --git a/docs/images/loginkey.jpg b/docs/images/loginkey.jpg
index 00d267a..d905136 100644
Binary files a/docs/images/loginkey.jpg and b/docs/images/loginkey.jpg differ
diff --git a/docs/images/loginkey2.jpg b/docs/images/loginkey2.jpg
index 00d267a..d905136 100644
Binary files a/docs/images/loginkey2.jpg and b/docs/images/loginkey2.jpg differ
diff --git a/kube-install.go b/kube-install.go
index 37a0b2e..e70c133 100644
--- a/kube-install.go
+++ b/kube-install.go
@@ -14,16 +14,7 @@ import (
func main() {
- var exec string
- var master string
- var node string
- var k8sver string
- var ostype string
- var softdir string
- var label string
- var sship string
- var sshpass string
- var listen string
+ var exec,master,node,k8sver,ostype,softdir,label,sship,sshpass,listen,upgradekernel string
initFlag := flag.Bool("init",false,"Initialize the local system environment.")
iFlag := flag.Bool("i",false,"Initialize the local system environment.")
@@ -42,8 +33,9 @@ func main() {
flag.StringVar(&node,"node","","The IP address of k8s node server filled in for the first installation")
flag.StringVar(&ostype,"ostype","","Specifies the distribution operating system type: centos7 | centos8 | rhel7 | rhel8 | ubuntu20 | suse15")
flag.StringVar(&k8sver,"k8sver","","Specifies the version of k8s software installed.(Default is \"kubernetes 1.22\")")
+ flag.StringVar(&upgradekernel,"upgradekernel","no","Because the lower versions of CentOS 7 and redhat 7 may lack kernel modules, only the kernel automatic upgrade of CentOS 7 and rhel7 operating systems is supported here, and other operating systems do not need to be upgraded. (Default is \"no\")")
flag.StringVar(&softdir,"softdir","","Specifies the installation directory of kubernetes cluster.(Default is \"/exec/kube-install\")")
- flag.StringVar(&label,"label",".default","In the case of deploying and operating multiple kubernetes clusters, it is necessary to specify a label to uniquely identify a kubernetes cluster.")
+ flag.StringVar(&label,"label",".default","In the case of deploying and operating multiple kubernetes clusters, it is necessary to specify a label to uniquely identify a kubernetes cluster. (Length must be less than 32 strings)")
flag.StringVar(&sship,"sship","","The IP address of the target host through which the SSH channel is opened.(Use with \"sshcontrol\")")
flag.StringVar(&sshpass,"sshpass","","The SSH password of the target host through which the SSH channel is opened.(Use with \"sshcontrol\")")
flag.Parse()
@@ -58,8 +50,8 @@ func main() {
// Set the version number and release date of Kube-Install.
const (
- Version string = "v0.7.2"
- ReleaseDate string = "10/22/2021"
+ Version string = "v0.7.3"
+ ReleaseDate string = "12/8/2021"
CompatibleK8S string = "1.17, 1.18, 1.19, 1.20, 1.21, 1.22, and 1.23"
CompatibleOS string = "CentOS linux 7, CentOS linux 8, RHEL 7, RHEL 8, Ubuntu 20, and SUSE 15"
)
@@ -72,6 +64,7 @@ func main() {
fmt.Println("\nInitialization in progress, please wait...\n")
kilib.CreateDir(currentDir+"/data/config", currentDir, logName, "")
kilib.CreateFile(currentDir+"/data/config/language.txt", currentDir, logName, "")
+ kilib.CreateFile(currentDir+"/data/config/tools.txt", currentDir, logName, "")
kilib.CreateDir(currentDir+"/data/output", currentDir, logName, "")
kilib.CreateDir(currentDir+"/data/logs", currentDir, logName, "")
kilib.CreateDir(currentDir+"/data/msg", currentDir, logName, "")
@@ -119,22 +112,24 @@ func main() {
case *showk8sFlag , *sFlag :
labelArray,err := kilib.GetAllDir(currentDir+"/data/output",currentDir,logName,"")
kilib.CheckErr(err,currentDir,logName,"")
- fmt.Println("---------------------------┬-----------┬---------------------┬-----------------------------------┬-------------------------------\n Label Of K8S Cluster | Version | Installation Status | Resource File Directory | K8S-Master Information \n---------------------------┼-----------┼---------------------┼-----------------------------------┼-------------------------------")
+ fmt.Println("---------------------------------┬-----------┬----------------┬-------------------------------------┬---------------------------------\n Kubernetes Cluster Label | Version | Install Status | Install Resource Directory | Kubernetes Master Information \n---------------------------------┼-----------┼----------------┼-------------------------------------┼---------------------------------")
for _, i := range labelArray {
- label1 := " | "
- k8sver1 := " | "
- status1 := " | "
- softDir1 := " |"
- label2 := string(i)
- k8sver2 := "k8s "+kilib.GetClusterK8sVer(label2,currentDir,"")
- status2,_ := kilib.GetClusterStatus(label2,currentDir,logName,"")
- softDir2 := kilib.GetClusterSoftdir(label2,currentDir,"")
- if len(softDir2) < len(softDir1) { softDir2 = softDir2 + softDir1[len(softDir2):len(softDir1)] }
- master2 := kilib.GetClusterMaster(label2,currentDir,logName,"")
- fmt.Printf(" " + label2 + label1[len(label2):len(label1)] + k8sver2 + k8sver1[len(k8sver2):len(k8sver1)] + status2 + status1[len(status2):len(status1)] + softDir2+" ")
- fmt.Println(master2)
+ var label2,softDir2 string
+ labelInit := " | "
+ k8sverInit := " | "
+ statusInit := " | "
+ softDirInit := " |"
+ label := string(i)
+ if len(label) < len(labelInit) { label2 = label + labelInit[len(label):len(labelInit)] } else { label2 = label + " | " }
+ k8sver := "k8s "+kilib.GetClusterK8sVer(label,currentDir,"")
+ status,_ := kilib.GetClusterStatus(label,currentDir,logName,"")
+ softDir := kilib.GetClusterSoftdir(label,currentDir,"")
+ if len(softDir) < len(softDirInit) { softDir2 = softDir + softDirInit[len(softDir):len(softDirInit)] } else { softDir2 = softDir + " |" }
+ master := kilib.GetClusterMaster(label,currentDir,logName,"")
+ fmt.Printf(" " + label2 + k8sver + k8sverInit[len(k8sver):len(k8sverInit)] + status + statusInit[len(status):len(statusInit)] + softDir2+" ")
+ fmt.Println(master)
}
- fmt.Println("---------------------------┴-----------┴---------------------┴-----------------------------------┴-------------------------------")
+ fmt.Println("---------------------------------┴-----------┴----------------┴-------------------------------------┴---------------------------------")
// View software version details.
case *versionFlag , *vFlag :
@@ -163,15 +158,18 @@ func main() {
case exec == "install" :
kilib.CheckParam(exec,"master",master)
kilib.CheckParam(exec,"node",node)
+ if !kilib.CheckLabel(label) {
+ panic("\nThe \"-ostype\" parameter length must be less than 32 strings, please check! \n\n ")
+ }
masterArray,nodeArray,softdir,subProcessDir,ostypeResult := kilib.ParameterConvert("", master, node, softdir, label, ostype)
kilib.DatabaseInit(currentDir,subProcessDir,logName,"")
- kilib.InstallCore("",master,masterArray,node,nodeArray,softdir,currentDir,kissh,subProcessDir,currentUser,label,ostypeResult,ostype,k8sver,logName,Version,CompatibleK8S,CompatibleOS,"","newinstall")
+ kilib.InstallCore("",master,masterArray,node,nodeArray,softdir,currentDir,kissh,subProcessDir,currentUser,label,ostypeResult,ostype,k8sver,logName,Version,CompatibleK8S,CompatibleOS,"","newinstall",upgradekernel)
//Execute addnode command
case exec == "addnode" :
kilib.CheckParam(exec,"node",node)
_,nodeArray,_,subProcessDir,ostypeResult := kilib.ParameterConvert("", "", node, softdir, label, ostype)
- kilib.AddNodeCore("",node,nodeArray,currentDir,kissh,subProcessDir,currentUser,label,softdir,ostypeResult,logName,CompatibleOS)
+ kilib.AddNodeCore("",node,nodeArray,currentDir,kissh,subProcessDir,currentUser,label,softdir,ostypeResult,logName,CompatibleOS,upgradekernel)
//Execute delnode command
case exec == "delnode" :
diff --git a/kube-install.service b/kube-install.service
index 8095c05..d9fad70 100644
--- a/kube-install.service
+++ b/kube-install.service
@@ -1,5 +1,5 @@
[Unit]
-Description=The highly available multiple kubernetes cluster can be installed offline with one click.
+Description=The highly available multiple kubernetes cluster can be installed offline with one click.
Documentation=https://cloudnativer.github.io
After=sshd.service
Requires=sshd.service
diff --git a/lib/check.go b/lib/check.go
index 28c31c1..bfb5530 100644
--- a/lib/check.go
+++ b/lib/check.go
@@ -69,6 +69,15 @@ func CheckPort(port int) bool {
}
}
+// Check whether the cluster label is correct.
+func CheckLabel(label string) bool {
+ if len(label) > 32 {
+ return false
+ } else {
+ return true
+ }
+}
+
// Check whether the parameters are input normally.
func CheckParam(option string, paramName string, param string) {
if param == "" {
diff --git a/lib/common.go b/lib/common.go
index 7d6ef17..8e42597 100644
--- a/lib/common.go
+++ b/lib/common.go
@@ -203,4 +203,3 @@ func LogStr(mode string) string {
}
return logStr
}
-
diff --git a/lib/core.go b/lib/core.go
index 3f90c09..ff4f34c 100644
--- a/lib/core.go
+++ b/lib/core.go
@@ -103,9 +103,17 @@ func DeleteMasterCore(mode string, masterArray []string, currentDir string, kiss
}
// Add the core operation part of the node.
-func AddNodeCore(mode string, node string, nodeArray []string, currentDir string, kissh string, subProcessDir string, currentUser string, label string, softDir string, osTypeResult string, logName string, CompatibleOS string) {
+func AddNodeCore(mode string, node string, nodeArray []string, currentDir string, kissh string, subProcessDir string, currentUser string, label string, softDir string, osTypeResult string, logName string, CompatibleOS string, upgradeKernel string) {
opt := "addnode"
logStr := LogStr(mode)
+ upgradeKernelStr := "\n Automatically Upgrade OS Kernel: Not Support"
+ if osTypeResult == "centos7" || osTypeResult == "rhel7" {
+ if upgradeKernel == "yes"{
+ upgradeKernelStr = "\n Automatically Upgrade OS Kernel: YES"
+ } else {
+ upgradeKernelStr = "\n Automatically Upgrade OS Kernel: NO"
+ }
+ }
CheckOS(CompatibleOS, osTypeResult, currentDir, logName, mode)
CreateDir(currentDir+"/data/output"+subProcessDir, currentDir, logName, mode)
for i := 0; i < len(nodeArray); i++ {
@@ -116,7 +124,7 @@ func AddNodeCore(mode string, node string, nodeArray []string, currentDir string
}
os.OpenFile(currentDir+"/data/logs"+subProcessDir+"/logs/addnode.log", os.O_RDWR|os.O_TRUNC|os.O_CREATE, 0766)
ShellExecute("echo \"*************************************************************************************\n\n[Info] "+time.Now().String()+" Adding kubernetes node, please wait ... \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/addnode.log")
- ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Node: "+node+"\n System User for Operation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/addnode.log")
+ ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Node: "+node+ upgradeKernelStr +"\n System User for Operation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/addnode.log")
ShellExecute("sed -i '1d' "+currentDir+"/data/msg/msg.txt")
ShellExecute("echo \"
[Info] "+time.Now().String()+" Adding kubernetes node to "+label+" cluster ...
\" >> "+currentDir+"/data/msg/msg.txt")
if !AddnodeConfig(mode, nodeArray, currentDir, subProcessDir, logName) {
@@ -126,7 +134,7 @@ func AddNodeCore(mode string, node string, nodeArray []string, currentDir string
ShellExecute("echo [Error] "+time.Now().String()+" \"The parameters you entered are incorrect, please check! \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/addnode.log")
return
}
- AddnodeYML("",currentDir+"/data/output"+subProcessDir,currentDir,currentUser,osTypeResult,logName)
+ AddnodeYML("",currentDir+"/data/output"+subProcessDir,currentDir,currentUser,logName,upgradeKernel,osTypeResult)
err_addnode := ExecuteOpt(kissh, currentDir, opt, opt, subProcessDir, "")
if err_addnode != nil {
for i := 0; i < len(nodeArray); i++ {
@@ -202,10 +210,18 @@ func DeleteNodeCore(mode string, nodeArray []string, currentDir string, kissh st
}
// Install the core operation part of the cluster.
-func InstallCore(mode string, master string, masterArray []string, node string, nodeArray []string, softDir string, currentDir string, kissh string, subProcessDir string, currentUser string, label string, osTypeResult string, osType string, k8sVer string, logName string, Version string, CompatibleK8S string, CompatibleOS string, installTime string, way string) {
+func InstallCore(mode string, master string, masterArray []string, node string, nodeArray []string, softDir string, currentDir string, kissh string, subProcessDir string, currentUser string, label string, osTypeResult string, osType string, k8sVer string, logName string, Version string, CompatibleK8S string, CompatibleOS string, installTime string, way string, upgradeKernel string) {
opt := "install"
layoutName := "install"
logStr := LogStr(mode)
+ upgradeKernelStr := "\n Automatically Upgrade OS Kernel: Not Support"
+ if osTypeResult == "centos7" || osTypeResult == "rhel7" {
+ if upgradeKernel == "yes"{
+ upgradeKernelStr = "\n Automatically Upgrade OS Kernel: YES"
+ } else {
+ upgradeKernelStr = "\n Automatically Upgrade OS Kernel: NO"
+ }
+ }
CheckOS(CompatibleOS, osTypeResult, currentDir, logName, mode)
CheckK8sVersion(Version, CompatibleK8S, k8sVer, currentDir, logName, mode)
CreateDir(currentDir+"/data/output"+subProcessDir, currentDir, logName, mode)
@@ -238,14 +254,14 @@ func InstallCore(mode string, master string, masterArray []string, node string,
InstallIpvsYaml(mode, currentDir, masterArray, subProcessDir, logName)
var err_install error
if len(masterArray) == 1{
- OnemasterInstallYML(mode,currentDir+"/data/output"+subProcessDir,currentDir,currentUser,osTypeResult,logName)
+ OnemasterInstallYML(mode,currentDir+"/data/output"+subProcessDir,currentDir,currentUser,logName, upgradeKernel,osTypeResult)
layoutName = "onemasterinstall"
}else{
- InstallYML(mode,currentDir+"/data/output"+subProcessDir, currentDir, currentUser, osTypeResult, logName)
+ InstallYML(mode,currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName, upgradeKernel,osTypeResult)
}
if installTime != "" {
ShellExecute("echo \"*************************************************************************************\n\n[Info] "+time.Now().String()+" Start scheduled installation task, please wait ... \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
- ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Version: Kubernetes v"+k8sVer+"\n Kubernetes Master: "+master+"\n Kubernetes Node: "+node+"\n Operating System Type: "+osType+"\n System User for Installation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
+ ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Version: Kubernetes v"+k8sVer+"\n Kubernetes Master: "+master+"\n Kubernetes Node: "+node+"\n Operating System Type: "+osType+ upgradeKernelStr +"\n System User for Installation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
DatabaseUpdate(currentDir+"/data/output"+subProcessDir+"/softdirtemp.txt", softDir, currentDir, logName, mode)
DatabaseUpdate(currentDir+"/data/output"+subProcessDir+"/ostypetemp.txt", osType, currentDir, logName, mode)
DatabaseUpdate(currentDir+"/data/output"+subProcessDir+"/k8svertemp.txt", k8sVer, currentDir, logName, mode)
@@ -254,7 +270,7 @@ func InstallCore(mode string, master string, masterArray []string, node string,
return
} else {
ShellExecute("echo \"*************************************************************************************\n\n[Info] "+time.Now().String()+" Installing kubernetes cluster, please wait ... \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
- ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Version: Kubernetes v"+k8sVer+"\n Kubernetes Master: "+master+"\n Kubernetes Node: "+node+"\n Operating System Type: "+osType+"\n System User for Installation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
+ ShellExecute("echo \" Kubernetes Cluster Label: "+label+"\n Kubernetes Version: Kubernetes v"+k8sVer+"\n Kubernetes Master: "+master+"\n Kubernetes Node: "+node+"\n Operating System Type: "+osType+ upgradeKernelStr +"\n System User for Installation: "+currentUser+"\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
sch,_ := ReadFile(currentDir+"/data/output"+subProcessDir+"/scheduler.txt")
if sch == "on" {
ShellExecute("echo [Error] "+time.Now().String()+" \"Installation conflict! Background scheduled tasks exist and installation is in progress.\n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/install.log")
diff --git a/lib/daemon.go b/lib/daemon.go
index b321f12..b2967d5 100644
--- a/lib/daemon.go
+++ b/lib/daemon.go
@@ -1,7 +1,8 @@
package kilib
import (
- // "fmt"
+// "fmt"
+
"html/template"
"io"
"net/http"
@@ -41,14 +42,15 @@ type ClusterList struct {
}
type ClusterAddForm struct {
- Master string `form:"master" binding:"required"`
- Node string `form:"node" binding:"required"`
- Ostype string `form:"ostype" binding:"required"`
- K8sver string `form:"k8sver" binding:"required"`
- Label string `form:"label" binding:"required"`
- Softdir string `form:"softdir"`
- Installtime string `form:"installtime"`
- Way string `form:"way"`
+ Master string `form:"master" binding:"required"`
+ Node string `form:"node" binding:"required"`
+ Ostype string `form:"ostype" binding:"required"`
+ K8sver string `form:"k8sver" binding:"required"`
+ Label string `form:"label" binding:"required"`
+ Softdir string `form:"softdir"`
+ Installtime string `form:"installtime"`
+ Way string `form:"way"`
+ Upgradekernel string `form:"upgradekernel"`
}
type ClusterDelForm struct {
@@ -104,11 +106,12 @@ type NodeList struct {
}
type NodeAddForm struct {
- Node string `form:"addnode" binding:"required"`
- Label string `form:"label" binding:"required"`
- K8sver string `form:"k8sver" binding:"required"`
- Softdir string `form:"softdir" binding:"required"`
- Ostype string `form:"ostype" binding:"required"`
+ Node string `form:"addnode" binding:"required"`
+ Label string `form:"label" binding:"required"`
+ K8sver string `form:"k8sver" binding:"required"`
+ Softdir string `form:"softdir" binding:"required"`
+ Ostype string `form:"ostype" binding:"required"`
+ Upgradekernel string `form:"upgradekernel"`
}
type NodeDelForm struct {
@@ -129,6 +132,12 @@ type SelectList struct {
Status string `json:"status"`
}
+type ToolSwitchForm struct {
+ Sshtool string `form:"sshtool" binding:"required"`
+ Installtool string `form:"installtool" binding:"required"`
+ Calendartool string `form:"calendartool" binding:"required"`
+}
+
type SshKeyForm struct {
Sship string `form:"sship" binding:"required"`
Sshpass string `form:"sshpass" binding:"required"`
@@ -613,6 +622,10 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
router.GET("/tools", func(c *gin.Context) {
langFromWeb := c.Query("lang")
Lang := ChangeLang(langFromWeb, currentDir, logName, mode)
+ toolSwitch := GetToolSwitch(currentDir, logName, mode)
+ sshTool := toolSwitch[0]
+ installTool := toolSwitch[1]
+ calendarTool := toolSwitch[2]
label := c.DefaultQuery("label", "")
k8sVer := c.DefaultQuery("k8sver", "")
softDir := c.DefaultQuery("softdir", "/opt/kube-install")
@@ -620,6 +633,9 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
c.HTML(http.StatusOK, "tools.tmpl", gin.H{
"Lang": Lang,
"Label": label,
+ "Sshtool": sshTool,
+ "Installtool": installTool,
+ "Calendartool": calendarTool,
"K8sver": k8sVer,
"Softdir": softDir,
"Ostype": osType,
@@ -725,7 +741,7 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
// operation of install
router.POST("/install", func(c *gin.Context) {
var form ClusterAddForm
- var master, node, osType, k8sVer, softDir, label, installTime, way string
+ var master, node, osType, k8sVer, softDir, label, installTime, way, upgradeKernel string
if c.ShouldBind(&form) == nil {
master = form.Master
node = form.Node
@@ -735,6 +751,7 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
label = form.Label
installTime = form.Installtime
way = form.Way
+ upgradeKernel = form.Upgradekernel
} else {
master = c.Query("master")
node = c.Query("node")
@@ -744,10 +761,15 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
label = c.DefaultQuery("label", "")
installTime = c.DefaultQuery("installtime", "")
way = c.DefaultQuery("way", "newinstall")
+ upgradeKernel = c.DefaultQuery("upgradekernel", "")
}
- langFromWeb := c.Query("lang")
- Lang := ChangeLang(langFromWeb, currentDir, logName, mode)
- tools := c.Query("tools")
+ langFromWeb := c.Query("lang")
+ Lang := ChangeLang(langFromWeb, currentDir, logName, mode)
+ tools := c.Query("tools")
+ if !CheckLabel(label) {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "install", "Result": "failure", "Info": "Installation failed! The \"label\" parameter length must be less than 32 strings, please check!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ return
+ }
if osType == "unknow" {
c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "install", "Result": "failure", "Info": "Installation failed! Please set the operating system type correctly!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
return
@@ -778,7 +800,7 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
stu, sch := GetClusterStatus(label, currentDir, logName, mode)
var installInfo string
if stu != "installing" && stu != "restarting" && stu != "uninstalling" && sch != "on" {
- go InstallCore(mode, master, masterArray, node, nodeArray, softDir, currentDir, kissh, subProcessDir, currentUser, label, osTypeResult, osType, k8sVer, logName, Version, CompatibleK8S, CompatibleOS, installTime, way)
+ go InstallCore(mode, master, masterArray, node, nodeArray, softDir, currentDir, kissh, subProcessDir, currentUser, label, osTypeResult, osType, k8sVer, logName, Version, CompatibleK8S, CompatibleOS, installTime, way, upgradeKernel )
if installTime == "" {
if Lang == "cn" {
installInfo = "Kubernetes集群正在后台安装中 ... "
@@ -900,19 +922,21 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
// operation of add node
router.POST("/addnode", func(c *gin.Context) {
var form NodeAddForm
- var node, softDir, label, k8sVer, osType string
+ var node, softDir, label, k8sVer, osType, upgradeKernel string
if c.ShouldBind(&form) == nil {
node = form.Node
softDir = form.Softdir
label = form.Label
k8sVer = form.K8sver
osType = form.Ostype
+ upgradeKernel = form.Upgradekernel
} else {
node = c.Query("node")
softDir = c.DefaultQuery("softdir", "/opt/kube-install")
label = c.DefaultQuery("label", "")
k8sVer = c.DefaultQuery("k8sver", "")
osType = c.DefaultQuery("ostype", "")
+ upgradeKernel = c.DefaultQuery("upgradekernel", "")
}
langFromWeb := c.Query("lang")
Lang := ChangeLang(langFromWeb, currentDir, logName, mode)
@@ -945,7 +969,7 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
}
}
}
- go AddNodeCore(mode, node, nodeArray, currentDir, kissh, subProcessDir, currentUser, label, softDir, osTypeResult, logName, CompatibleOS)
+ go AddNodeCore(mode, node, nodeArray, currentDir, kissh, subProcessDir, currentUser, label, softDir, osTypeResult, logName, CompatibleOS, upgradeKernel )
if Lang == "cn" {
c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "addnode", "Result": "success", "Info": "Kubernetes node正在后台添加中 ...", "Softdir": softDir, "Ostype": osType, "Tools": "no", "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
} else {
@@ -1082,6 +1106,44 @@ func DaemonRun(Version string, ReleaseDate string, CompatibleK8S string, Compati
c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "deleteschedule", "Result": scheduleResult, "Info": scheduleInfo, "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
})
+ // Set tools switch
+ router.POST("/toolswitch", func(c *gin.Context) {
+ var form ToolSwitchForm
+ var sshTool, installTool, calendarTool string
+ tools := c.Query("tools")
+ label := c.DefaultQuery("label", "")
+ k8sVer := c.DefaultQuery("k8sver", "")
+ softDir := c.DefaultQuery("softdir", "/opt/kube-install")
+ osType := c.DefaultQuery("ostype", "")
+ langFromWeb := c.Query("lang")
+ Lang := ChangeLang(langFromWeb, currentDir, logName, mode)
+ if c.ShouldBind(&form) == nil {
+ sshTool = form.Sshtool
+ installTool = form.Installtool
+ calendarTool = form.Calendartool
+ err := SetToolSwitch(sshTool, installTool, calendarTool, currentDir, logName, mode)
+ if err != nil {
+ if Lang == "cn" {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "failure", "Info": "工具面板设置操作失败!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ } else {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "failure", "Info": "Failed to set the tool panel!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ }
+ } else {
+ if Lang == "cn" {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "success", "Info": "工具面板设置操作成功!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ } else {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "success", "Info": "Tool panel setting operation succeeded!", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ }
+ }
+ } else {
+ if Lang == "cn" {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "failure", "Info": "设置失败!请确保你设置了正确的选项。", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ } else {
+ c.HTML(http.StatusOK, "optresult.tmpl", gin.H{"Label": label, "K8sver": k8sVer, "Opt": "toolswitch", "Result": "failure", "Info": "Setting failed! Please make sure you set the correct options.", "Softdir": softDir, "Ostype": osType, "Tools": tools, "Lang": Lang, "Version": Version, "Releasedate": ReleaseDate, "Compatiblek8s": CompatibleK8S, "Compatibleos": CompatibleOS})
+ }
+ }
+ })
+
// Open the SSH key channel
router.POST("/sshkey", func(c *gin.Context) {
var form SshKeyForm
diff --git a/lib/help.go b/lib/help.go
index 5566949..6adffae 100644
--- a/lib/help.go
+++ b/lib/help.go
@@ -29,11 +29,12 @@ COMMAND:
OBJECT:
k8sver Specifies the version of k8s software installed.(Default is "1.22")
- label In the case of deploying and operating multiple kubernetes clusters, it is necessary to specify a label to uniquely identify a kubernetes cluster.
+ label In the case of deploying and operating multiple kubernetes clusters, it is necessary to specify a label to uniquely identify a kubernetes cluster.(Length must be less than 32 strings)
listen Set the IP and port on which the daemon service listens.(Default is "0.0.0.0:9080")
master The IP address of kubernetes master host.
node The IP address of kubernetes node host.
ostype Specifies the distribution OS type: "centos7 | centos8 | rhel7 | rhel8 | ubuntu20 | suse15".
+ upgradekernel Because the lower versions of CentOS 7 and redhat 7 may lack kernel modules, only the kernel automatic upgrade of CentOS 7 and rhel7 operating systems is supported here, and other operating systems do not need to be upgraded.(Default is "no")
softdir Specifies the installation directory of kubernetes cluster.(Default is "/opt/kube-install")
sship The IP address of the target host through which the SSH channel is opened.(Use with "sshcontrol")
sshpass The root password of the target host through which the SSH channel is opened.(Use with "sshcontrol")
@@ -42,19 +43,19 @@ OBJECT:
EXAMPLES:
Initialize the system environment:
- kube-install -init -ostype "rhel7"
+ kube-install -init -ostype "rhel8"
Open the SSH channel from the local to the target host (You can also get through manually):
kube-install -exec sshcontrol -sship "192.168.1.11,192.168.1.12,192.168.1.13,192.168.1.14" -sshpass "cloudnativer"
Install kubernetes cluster:
- kube-install -exec install -master "192.168.1.11,192.168.1.12,192.168.1.13" -node "192.168.1.11,192.168.1.12,192.168.1.13,192.168.1.14" -k8sver "1.22" -ostype "rhel7" -label "192168001011"
+ kube-install -exec install -master "192.168.1.11,192.168.1.12,192.168.1.13" -node "192.168.1.11,192.168.1.12,192.168.1.13,192.168.1.14" -k8sver "1.22" -ostype "rhel8" -label "192168001011"
Add node to the kubernetes cluster:
- kube-install -exec addnode -node "192.168.1.15,192.168.1.16" -k8sver "1.22" -ostype "rhel7" -label "192168001011"
+ kube-install -exec addnode -node "192.168.1.15,192.168.1.16" -k8sver "1.22" -ostype "rhel8" -label "192168001011"
Remove the node from the kubernetes cluster:
kube-install -exec delnode -node "192.168.1.13,192.168.1.15" -label "192168001011"
Remove the master from the kubernetes cluster:
kube-install -exec delmaster -master "192.168.1.13" -label "192168001011"
rebuild the damaged kubernetes master:
- kube-install -exec rebuildmaster -master "192.168.1.13" -k8sver "1.22" -ostype "rhel7" -label "192168001011"
+ kube-install -exec rebuildmaster -master "192.168.1.13" -k8sver "1.22" -ostype "rhel8" -label "192168001011"
Uninstall kubernetes cluster:
kube-install -exec uninstall -master "192.168.1.11,192.168.1.12,192.168.1.13" -node "192.168.1.11,192.168.1.12,192.168.1.13,192.168.1.14" -label "192168001011"
Enable this switch to use the web console for management:
diff --git a/lib/layout.go b/lib/layout.go
index e8f954d..1ca030c 100644
--- a/lib/layout.go
+++ b/lib/layout.go
@@ -6,10 +6,12 @@ import (
// Generate orchestration for install.
-func InstallYML(mode string, softDir string, currentDir string, currentUser string, osType string, logName string) {
+func InstallYML(mode string, softDir string, currentDir string, currentUser string, logName string, upgradeKernel string, osTypeResult string) {
var osCompatibilityLayout string
- if (osType == "centos7") || (osType == "rhel7") {
- osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ if upgradeKernel == "yes" {
+ if osTypeResult == "centos7" || osTypeResult == "rhel7" {
+ osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ }
}
install_file, err := os.Create(softDir+"/k8scluster-install.yml")
CheckErr(err,currentDir,logName,mode)
@@ -18,10 +20,12 @@ func InstallYML(mode string, softDir string, currentDir string, currentUser stri
}
// Generate orchestration for install one master.
-func OnemasterInstallYML(mode string, softDir string, currentDir string, currentUser string, osType string, logName string) {
+func OnemasterInstallYML(mode string, softDir string, currentDir string, currentUser string, logName string, upgradeKernel string, osTypeResult string) {
var osCompatibilityLayout string
- if (osType == "centos7") || (osType == "rhel7") {
- osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ if upgradeKernel == "yes" {
+ if osTypeResult == "centos7" || osTypeResult == "rhel7" {
+ osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ }
}
onemasterinstall_file, err := os.Create(softDir+"/k8scluster-onemasterinstall.yml")
CheckErr(err,currentDir,logName,mode)
@@ -30,10 +34,12 @@ func OnemasterInstallYML(mode string, softDir string, currentDir string, current
}
// Generate orchestration for add node.
-func AddnodeYML(mode string, softDir string, currentDir string, currentUser string, osType string, logName string) {
+func AddnodeYML(mode string, softDir string, currentDir string, currentUser string, logName string, upgradeKernel string, osTypeResult string) {
var osCompatibilityLayout string
- if (osType == "centos7") || (osType == "rhel7") {
- osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ if upgradeKernel == "yes" {
+ if osTypeResult == "centos7" || osTypeResult == "rhel7" {
+ osCompatibilityLayout = "- remote_user: root\n hosts: node\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x0000000000base/kernel\n"
+ }
}
addnode_file, err := os.Create(softDir+"/k8scluster-addnode.yml")
CheckErr(err,currentDir,logName,mode)
diff --git a/lib/tools.go b/lib/tools.go
new file mode 100644
index 0000000..9be5b19
--- /dev/null
+++ b/lib/tools.go
@@ -0,0 +1,27 @@
+package kilib
+
+import (
+ "strings"
+)
+
+
+// Read tools switch information
+func GetToolSwitch(currentDir string, logName string, mode string) []string {
+ toolSwitch := []string{"on", "on", "on"}
+ toolSwitchData, _ := ReadFile(currentDir + "/data/config/tools.txt")
+ if toolSwitchData != "" {
+ toolSwitch = strings.Split(toolSwitchData, ",")
+ }
+ return toolSwitch
+}
+
+// Switch tools status
+func SetToolSwitch(sshTool string, installTool string, calendarTool string, currentDir string, logName string, mode string) error {
+ toolswitch := sshTool + "," + installTool + "," + calendarTool
+ err := DatabaseUpdate(currentDir+"/data/config/tools.txt", toolswitch, currentDir, logName, mode)
+ return err
+}
+
+
+
+
diff --git a/static/html/1 b/static/html/1
new file mode 100644
index 0000000..24249e1
--- /dev/null
+++ b/static/html/1
@@ -0,0 +1,367 @@
+
+
+
+
+
+
+ {{if eq .Lang "cn"}}Kube-Install(二进制方式部署K8S集群){{else}}Kube-Install(installation of K8S in binary mode){{end}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kube-Install Version {{.Version}} | Powered By CloudNativer
+
+
+
+
+
diff --git a/static/html/calendarscheduler.tmpl b/static/html/calendarscheduler.tmpl
index 6d6417c..b1325be 100644
--- a/static/html/calendarscheduler.tmpl
+++ b/static/html/calendarscheduler.tmpl
@@ -98,7 +98,7 @@
- {{if eq .Lang "cn"}}*.上面的日历中会显示Kubernetes集群标签、正在安装或计划安装的时间日程。(如果是刚制定的安装任务计划,可能需要等待1分钟后才能显示到日历上面) {{else}}*.The calendar above shows the kubernetes cluster label, the time schedule of the installation in progress or planned. (The task plan just made needs to wait 1 minute to display) {{end}}
+ {{if eq .Lang "cn"}}*.上面的日历中会显示正在安装或计划安装的时间日程、Kubernetes集群标签。(如果是刚制定的安装任务计划,可能需要等待1分钟后才能显示到日历上面) {{else}}*.The calendar above shows the kubernetes cluster label, the time schedule of the installation in progress or planned. (The task plan just made needs to wait 1 minute to display) {{end}}
diff --git a/static/html/cluster.tmpl b/static/html/cluster.tmpl
index fbc58d2..c892f19 100644
--- a/static/html/cluster.tmpl
+++ b/static/html/cluster.tmpl
@@ -52,6 +52,22 @@
+
@@ -103,7 +119,7 @@
{{if eq .Lang "cn"}}Kubernetes集群标示{{else}}Kubernetes cluster label{{end}} *
-
{{if eq .Lang "cn"}}填写用于唯一识别这个Kubernetes{{if eq .Lang "cn"}}集群的{{else}}cluster{{end}}标示字段{{else}}Fill in the label field that uniquely identifies the kubernetes cluster{{end}}
+
{{if eq .Lang "cn"}}填写用于唯一识别这个Kubernetes集群的标示字段(Label长度必须小于32个字符){{else}}Fill in the label field that uniquely identifies the kubernetes cluster (Length must be less than 32 strings){{end}}
@@ -140,7 +156,7 @@
{{if eq .Lang "cn"}}操作系统类型{{else}}Operating system type{{end}}*
-
+
CentOS Linux 7
CentOS Linux 8
Red Hat Enterprise Linux 7
@@ -151,6 +167,13 @@
{{if eq .Lang "cn"}}选择目标主机的操作系统类型。相同批次的主机操作系统需要保持一致{{else}}Select the operating system type of the target host. Host operating systems of the same batch need to be consistent!{{end}}
+
+
{{if eq .Lang "cn"}}自动升级OS内核{{else}}Automatically upgrade OS kernel{{end}}
+
+
{{if eq .Lang "cn"}}部署到目标主机路径{{else}}Deploy to target host path{{end}} *