fix #1051: Best efforts to clear ipvs rules.

Signed-off-by: laminar <fangtian@kubesphere.io>
This commit is contained in:
laminar 2022-03-22 10:18:13 +08:00
parent 37dd9a4350
commit 3616986434
8 changed files with 17 additions and 8 deletions

View File

@ -80,6 +80,7 @@ KubeKey can install Kubernetes and KubeSphere together. The dependency that need
| `conntrack` | Required | Optional but recommended |
| `ebtables` | Optional but recommended | Optional but recommended |
| `ipset` | Optional but recommended | Optional but recommended |
| `ipvsadm` | Optional but recommended | Optional but recommended |
* Networking and DNS requirements:
* Make sure the DNS address in `/etc/resolv.conf` is available. Otherwise, it may cause some issues of DNS in cluster.

View File

@ -74,6 +74,7 @@ KubeKey 可以同时安装 Kubernetes 和 KubeSphere。根据 KubeSphere 所安
| `conntrack` | 必须安装 | 可选,但推荐安装 |
| `ebtables` | 可选,但推荐安装 | 可选,但推荐安装 |
| `ipset` | 可选,但推荐安装 | 可选,但推荐安装 |
| `ipvsadm` | 可选,但推荐安装 | 可选,但推荐安装 |
* 网络和 DNS 要求:
* 确保 `/etc/resolv.conf` 中的 DNS 地址可用。否则,可能会导致集群中出现某些 DNS 问题。

View File

@ -2,7 +2,7 @@
**kk init os**: Init operating system.
# DESCRIPTION
Init operating system. This command will install `openssl`, `socat`, `conntrack`, `ipset`, `ebtables` and `chrony` on all the nodes.
Init operating system. This command will install `openssl`, `socat`, `conntrack`, `ipset`, `ipvsadm`, `ebtables` and `chrony` on all the nodes.
# OPTIONS

View File

@ -42,6 +42,7 @@ type PreCheckResults struct {
Ebtables string `table:"ebtables"`
Socat string `table:"socat"`
Ipset string `table:"ipset"`
Ipvsadm string `table:"ipvsadm"`
Conntrack string `table:"conntrack"`
Chronyd string `table:"chrony"`
Docker string `table:"docker"`

View File

@ -78,7 +78,7 @@ func (d *Debian) Update() error {
func (d *Debian) Install(pkg ...string) error {
if len(pkg) == 0 {
pkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony"}
pkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
}
str := strings.Join(pkg, " ")

View File

@ -86,7 +86,7 @@ func (r *RedhatPackageManager) Update() error {
func (r *RedhatPackageManager) Install(pkg ...string) error {
if len(pkg) == 0 {
pkg = []string{"openssl", "socat", "conntrack", "ipset", "ebtables", "chrony"}
pkg = []string{"openssl", "socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
}
str := strings.Join(pkg, " ")

View File

@ -18,14 +18,15 @@ package os
import (
"fmt"
"path/filepath"
"strings"
osrelease "github.com/dominodatalab/os-release"
"github.com/kubesphere/kubekey/pkg/bootstrap/os/repository"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/connector"
"github.com/kubesphere/kubekey/pkg/utils"
"github.com/pkg/errors"
"path/filepath"
"strings"
)
type NodeConfigureOS struct {
@ -163,6 +164,7 @@ var (
"iptables -X",
"iptables -F -t nat",
"iptables -X -t nat",
"ipvsadm -C",
"ip link del kube-ipvs0",
"ip link del nodelocaldns",
}
@ -173,7 +175,9 @@ type ResetNetworkConfig struct {
}
func (r *ResetNetworkConfig) Execute(runtime connector.Runtime) error {
_, _ = runtime.GetRunner().SudoCmd(strings.Join(networkResetCmds, " && "), true)
for _, cmd := range networkResetCmds {
_, _ = runtime.GetRunner().SudoCmd(cmd, true)
}
return nil
}
@ -257,13 +261,13 @@ func (o *OnlineInstallDependencies) Execute(runtime connector.Runtime) error {
case "deb":
if _, err := runtime.GetRunner().SudoCmd(
"apt update;"+
"apt install socat conntrack ipset ebtables chrony -y;",
"apt install socat conntrack ipset ebtables chrony ipvsadm -y;",
false); err != nil {
return err
}
case "rpm":
if _, err := runtime.GetRunner().SudoCmd(
"yum install openssl socat conntrack ipset ebtables chrony -y",
"yum install openssl socat conntrack ipset ebtables chrony ipvsadm -y",
false); err != nil {
return err
}

View File

@ -24,6 +24,7 @@ const (
ebtables = "ebtables"
socat = "socat"
ipset = "ipset"
ipvsadm = "ipvsadm"
conntrack = "conntrack"
chrony = "chronyd"
docker = "docker"
@ -46,6 +47,7 @@ var baseSoftware = []string{
ebtables,
socat,
ipset,
ipvsadm,
conntrack,
chrony,
docker,