Skip to content

Commit

Permalink
Clean up residual files after uninstallation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudnativer committed Oct 9, 2021
1 parent 905d872 commit d1a175b
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ Notice: We use 192.168.1.11 as the kube-install host. In fact, you can use any h

You can download the `kube-install-*.tgz` package from https://github.com/cloudnativer/kube-install/releases. <br>

For example, we have downloaded the `kube-install-allinone-v0.7.0.tgz` package.<br>
For example, we have downloaded the `kube-install-allinone-v0.7.1.tgz` package.<br>

```
# cd /root/
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.0/kube-install-allinone-v0.7.0.tgz
# tar -zxvf kube-install-allinone-v0.7.0.tgz
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.1/kube-install-allinone-v0.7.1.tgz
# tar -zxvf kube-install-allinone-v0.7.1.tgz
# cd /root/kube-install/
```

Expand Down
6 changes: 3 additions & 3 deletions README0.7-jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@


あなたは https://github.com/cloudnativer/kube-install/releases ここで `kube-install-*.tgz` ソフトパッケージをダウンロードします。 <br>
例えば `kube-install-allinone-v0.7.0.tgz`パッケージをダウンロードしてインストールします:<br>
例えば `kube-install-allinone-v0.7.1.tgz`パッケージをダウンロードしてインストールします:<br>

```
# cd /root/
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.0/kube-install-allinone-v0.7.0.tgz
# tar -zxvf kube-install-allinone-v0.7.0.tgz
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.1/kube-install-allinone-v0.7.1.tgz
# tar -zxvf kube-install-allinone-v0.7.1.tgz
# cd /root/kube-install/
```

Expand Down
6 changes: 3 additions & 3 deletions README0.7-zh-hk.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
<br>

你可以從https://github.com/cloudnativer/kube-install/releases 這裡下載`kube-install-*.tgz`套裝軟體。<br>
舉例,下載`kube-install-allinone-v0.7.0.tgz`套裝軟體進行安裝:<br>
舉例,下載`kube-install-allinone-v0.7.1.tgz`套裝軟體進行安裝:<br>

```
# cd /root/
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.0/kube-install-allinone-v0.7.0.tgz
# tar -zxvf kube-install-allinone-v0.7.0.tgz
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.1/kube-install-allinone-v0.7.1.tgz
# tar -zxvf kube-install-allinone-v0.7.1.tgz
# cd /root/kube-install/
```

Expand Down
6 changes: 3 additions & 3 deletions README0.7-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
<br>

你可以从 https://github.com/cloudnativer/kube-install/releases 这里下载`kube-install-*.tgz`软件包。 <br>
举例,下载`kube-install-allinone-v0.7.0.tgz`软件包进行安装:<br>
举例,下载`kube-install-allinone-v0.7.1.tgz`软件包进行安装:<br>

```
# cd /root/
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.0/kube-install-allinone-v0.7.0.tgz
# tar -zxvf kube-install-allinone-v0.7.0.tgz
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.1/kube-install-allinone-v0.7.1.tgz
# tar -zxvf kube-install-allinone-v0.7.1.tgz
# cd /root/kube-install/
```

Expand Down
6 changes: 3 additions & 3 deletions README0.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ Notice: We use 192.168.1.11 as the kube-install host. In fact, you can use any h

You can download the `kube-install-*.tgz` package from https://github.com/cloudnativer/kube-install/releases. <br>

For example, we have downloaded the `kube-install-allinone-v0.7.0.tgz` package.<br>
For example, we have downloaded the `kube-install-allinone-v0.7.1.tgz` package.<br>

```
# cd /root/
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.0/kube-install-allinone-v0.7.0.tgz
# tar -zxvf kube-install-allinone-v0.7.0.tgz
# curl -O https://github.com/cloudnativer/kube-install/releases/download/v0.7.1/kube-install-allinone-v0.7.1.tgz
# tar -zxvf kube-install-allinone-v0.7.1.tgz
# cd /root/kube-install/
```

Expand Down
5 changes: 3 additions & 2 deletions docs/parameters0.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Usage of kube-install:
kube-install [OPTION] { [COMMAND] OBJECT [ARGS]... }
OPTIONS:
d, daemon Run as a daemon service. (Enable this switch to use the web console for management)
d, daemon Run as a daemon service.(Enable this switch to use the web console for management)
e, exec Deploy and uninstall kubernetes cluster.(Use with "init | sshcontrol | install | addnode | delnode | delmaster | rebuildmaster | uninstall")
h, help Display usage help information of kube-install.
i, init Initialize the local system environment.
Expand All @@ -37,8 +37,9 @@ COMMAND:
uninstall Uninstall kubernetes cluster.
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.
listen Set the IP and port on which the daemon service listens. (Default is "0.0.0.0:9080")
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".
Expand Down
Binary file modified kube-install
Binary file not shown.
8 changes: 4 additions & 4 deletions lib/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func DeleteMasterCore(mode string, masterArray []string, currentDir string, kiss
ShellExecute("echo [Error] "+time.Now().String()+" \"The parameters you entered are incorrect, please check! \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/delmaster.log")
return
}
DelmasterYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName)
DelmasterYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName, false)
err_delmaster := ExecuteOpt(kissh, currentDir, opt, opt, subProcessDir, "")
if err_delmaster != nil {
for i := 0; i < len(masterArray); i++ {
Expand Down Expand Up @@ -146,7 +146,7 @@ func DeleteNodeCore(mode string, nodeArray []string, currentDir string, kissh st
}
return
}
DelnodeYML("",currentDir+"/data/output"+subProcessDir,currentDir,currentUser,logName)
DelnodeYML("", currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName, false)
ExecuteDeleteNode(nodeArray, currentDir, subProcessDir, opt, mode)
ShellExecute("echo [Info] "+time.Now().String()+" \"The system is scheduling pod to other healthy nodes in the cluster. Please wait... \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/delnode.log")
time.Sleep(time.Duration(30)*time.Second)
Expand Down Expand Up @@ -326,8 +326,8 @@ func UninstallCore(mode string, master string, masterArray []string, node string
ShellExecute("echo [Error] "+time.Now().String()+" \"The parameters you entered are incorrect, please check! \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/uninstall.log")
return
}
DelmasterYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName)
DelnodeYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName)
DelmasterYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName, true)
DelnodeYML("",currentDir+"/data/output"+subProcessDir, currentDir, currentUser, logName, true)
ShellExecute("echo [Info] "+time.Now().String()+" \"Loading operation configuration ... \n\""+logStr+currentDir+"/data/logs"+subProcessDir+"/logs/uninstall.log")
err_delnode := ExecuteOpt(kissh, currentDir, opt, "delnode", subProcessDir, "")
if err_delnode != nil {
Expand Down
4 changes: 2 additions & 2 deletions lib/gencfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func GeneralConfig(mode string, masterArray []string, nodeArray []string, curren
}
// Addons IP Configuration
addonsIp1,addonsIp2,addonsIp3 := CreateAddonsNode(nodeArray)
inventory_file.WriteString("\n### addons_ip配置 ###\naddons_ip1=\""+addonsIp1+"\"\naddons_ip2=\""+addonsIp2+"\"\naddons_ip3=\""+addonsIp3+"\"\n")
inventory_file.WriteString("\n### addons_ip configuration ###\naddons_ip1=\""+addonsIp1+"\"\naddons_ip2=\""+addonsIp2+"\"\naddons_ip3=\""+addonsIp3+"\"\n")
DatabaseUpdate(currentDir+"/data/output"+subProcessDir+"/addons/addonsip/registryip.txt", addonsIp1, currentDir, logName, mode)
DatabaseUpdate(currentDir+"/data/output"+subProcessDir+"/addons/addonsip/k8sdashboardip.txt", addonsIp3, currentDir, logName, mode)
inventory_file.WriteString("\n### traefik configuration ###\ntraefik_admin_port=\"80\"\ntraefik_data_port=\"8080\"\n")
inventory_file.WriteString("\n### k8s network配置 ###\nservice_cidr=\"10.254.0.0/16\"\nservice_svc_ip=\"10.254.0.1\"\nservice_dns_svc_ip=\"10.254.0.2\"\npod_cidr=\"10.244.0.0/16\"\n\n\n")
inventory_file.WriteString("\n### k8s network configuration ###\nservice_cidr=\"10.254.0.0/16\"\nservice_svc_ip=\"10.254.0.1\"\nservice_dns_svc_ip=\"10.254.0.2\"\npod_cidr=\"10.244.0.0/16\"\n\n\n")
}

// Generate install configuration information.
Expand Down
7 changes: 4 additions & 3 deletions lib/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ func ShowHelp(){
kube-install [OPTION] { [COMMAND] OBJECT [ARGS]... }
OPTIONS:
d, daemon Run as a daemon service. (Enable this switch to use the web console for management)
d, daemon Run as a daemon service.(Enable this switch to use the web console for management)
e, exec Deploy and uninstall kubernetes cluster.(Use with "init | sshcontrol | install | addnode | delnode | delmaster | rebuildmaster | uninstall")
h, help Display usage help information of kube-install.
i, init Initialize the local system environment.
s, showk8s Display all deployed kubernetes cluster information.
s, showk8s Display all installed kubernetes cluster information.
v, version Display software version information of kube-install.
COMMAND:
Expand All @@ -28,8 +28,9 @@ COMMAND:
uninstall Uninstall kubernetes cluster.
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.
listen Set the IP and port on which the daemon service listens. (Default is "0.0.0.0:9080")
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".
Expand Down
16 changes: 12 additions & 4 deletions lib/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ func AddnodeYML(mode string, softDir string, currentDir string, currentUser stri
}

// Generate orchestration for delete node.
func DelnodeYML(mode string, softDir string, currentDir string, currentUser string, logName string) {
func DelnodeYML(mode string, softDir string, currentDir string, currentUser string, logName string, force bool) {
var clearFileStr string
if force{
clearFileStr = "- remote_user: root\n hosts: delnode\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/clearresidue\n"
}
delnode_file, err := os.Create(softDir+"/k8scluster-delnode.yml")
CheckErr(err,currentDir,logName,mode)
defer delnode_file.Close()
delnode_file.WriteString("- remote_user: root\n hosts: delnode\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/delnode\n")
delnode_file.WriteString("- remote_user: root\n hosts: delnode\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/delnode\n"+clearFileStr)
}

// Generate orchestration for rebuild master.
Expand All @@ -58,11 +62,15 @@ func RebuildmasterYML(mode string, softDir string, currentDir string, currentUse
}

// Generate orchestration for delete master.
func DelmasterYML(mode string, softDir string, currentDir string, currentUser string, logName string) {
func DelmasterYML(mode string, softDir string, currentDir string, currentUser string, logName string, force bool) {
var clearFileStr string
if force{
clearFileStr = "- remote_user: root\n hosts: delmaster\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/clearresidue\n"
}
delmaster_file, err := os.Create(softDir+"/k8scluster-delmaster.yml")
CheckErr(err,currentDir,logName,mode)
defer delmaster_file.Close()
delmaster_file.WriteString("- remote_user: root\n hosts: delmaster\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/delmaster\n")
delmaster_file.WriteString("- remote_user: root\n hosts: delmaster\n gather_facts: no\n roles:\n - "+softDir+"/sys/0x00000000action/delmaster\n"+clearFileStr)
}


2 changes: 1 addition & 1 deletion static/html/cluster.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
</td>
<td align="center">
{{ if eq $v.Scheduler "on" }} <img src="static/img/Icons/Preview/clock_enable.png" {{if eq .Lang "cn"}}title="已开启" alt="已开启"{{else}}title="Enabled" alt="Enabled"{{end}} style="vertical-align: middle;"/><br><span style="display: inline-block;">{{.Instime}}</span>
{{else}}<img src="static/img/Icons/Preview/clock_disable.png" {{if eq .Lang "cn"}}title="未开启" alt="未开启"{{else}}title="Enabled" alt="Enabled"{{end}} style="vertical-align: middle;"/><br><span style="display: inline-block;">{{if eq .Lang "cn"}}暂无{{else}}Disabled{{end}}</span>{{end}}
{{else}}<img src="static/img/Icons/Preview/clock_disable.png" {{if eq .Lang "cn"}}title="未开启" alt="未开启"{{else}}title="Disabled" alt="Disabled"{{end}} style="vertical-align: middle;"/><br><span style="display: inline-block;">{{if eq .Lang "cn"}}暂无{{else}}Disabled{{end}}</span>{{end}}
</td>
<td>
{{ if eq $v.Status "unknow" }} <a href="clusterinfo?label={{$v.K8t}}" style="background:#99FF99;">{{if eq $v.Lang "cn"}}查看详细{{else}}View Details{{end}}</a> | {{end}} {{ if eq $v.Status "ok" }} <a href="clusterinfo?label={{$v.K8t}}" style="background:#99FF99;">{{if eq $v.Lang "cn"}}查看详细{{else}}View Details{{end}}</a> | <a href="https://{{.K8sdashboardip}}:50000" target="_blank" style="background:#99FF99;">{{if eq $v.Lang "cn"}}Web控制台{{else}}Kube-Dashboard{{end}}</a> | <a href="masteradmin?label={{ $v.K8t }}&softdir={{ $v.Sdr }}&ostype={{ $v.Ostype }}&k8sver={{ $v.K8v }}" style="background:#CCFFFF;"> {{if eq $v.Lang "cn"}}Master管理{{else}}Master Management{{end}} </a> | <a href="nodeadmin?label={{ $v.K8t }}&softdir={{ $v.Sdr }}&ostype={{ $v.Ostype }}&k8sver={{ $v.K8v }}" style="background:#CCFFFF;"> {{if eq $v.Lang "cn"}}Node管理{{else}}Node Management{{end}} </a> | {{end}}
Expand Down
2 changes: 1 addition & 1 deletion static/html/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
<!-- Quick Statistics -->
<div class="g_3 quick_stats">
<div class="big_stats visitor_stats">
{{.K8snum}}
{{.K8snum}}
</div>
<h5 class="stats_info">{{if eq .Lang "cn"}}K8S集群数量{{else}}Number of Kubernetes{{end}}</h5>
</div>
Expand Down
47 changes: 47 additions & 0 deletions sys/0x00000000action/clearresidue/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- name: 1.Delete {{software_home}} dir
file:
path: "{{software_home}}"
state: absent
ignore_errors: yes
- name: 2.Delete cert file
file:
path: /etc/kubernetes
state: absent
ignore_errors: yes
- name: 3.Delete kubectl file
file:
path: /usr/sbin/kubectl
state: absent
ignore_errors: yes
- name: 4.Delete other bin file
file:
path: /usr/local/bin/{{item}}
state: absent
with_items:
- bandwidth
- dhcp
- flannel
- host-device
- ipvlan
- kubeadm
- kubectl
- kubectl-convert
- kubelet
- kube-proxy
- macvlan
- mounter
- ptp
- sbr
- tuning
- bridge
- firewall
- flanneld
- host-local
- ipvsinit.sh
- loopback
- mk-docker-opts.sh
- portmap
- resolvinit.sh
- static
- vlan
ignore_errors: yes
1 change: 0 additions & 1 deletion sys/0x00000000action/delnode/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@
state: absent
ignore_errors: yes


0 comments on commit d1a175b

Please sign in to comment.