From cee6b42e991a79a09b9901d8880fa65f91446224 Mon Sep 17 00:00:00 2001 From: zyjhtangtang Date: Fri, 12 Nov 2021 14:23:13 +0800 Subject: [PATCH] modeprobe br-netfilter to fix issue #568 (#578) --- pkg/yurtctl/util/system/util.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/yurtctl/util/system/util.go b/pkg/yurtctl/util/system/util.go index c30f2d2b995..a34907e1d19 100644 --- a/pkg/yurtctl/util/system/util.go +++ b/pkg/yurtctl/util/system/util.go @@ -19,11 +19,13 @@ package system import ( "fmt" "io/ioutil" + "os/exec" "k8s.io/klog" "github.com/opencontainers/selinux/go-selinux" "github.com/openyurtio/openyurt/pkg/yurtctl/constants" + "github.com/openyurtio/openyurt/pkg/yurtctl/util/edgenode" ) const ( @@ -51,6 +53,13 @@ func SetBridgeSetting() error { if err := ioutil.WriteFile(constants.Sysctl_k8s_config, []byte(kubernetsBridgeSetting), 0644); err != nil { return fmt.Errorf("Write file %s fail: %v ", constants.Sysctl_k8s_config, err) } + + if exist, _ := edgenode.FileExists(bridgenf); !exist { + cmd := exec.Command("bash", "-c", "modprobe br-netfilter") + if err := edgenode.Exec(cmd); err != nil { + return err + } + } if err := ioutil.WriteFile(bridgenf, []byte("1"), 0644); err != nil { return fmt.Errorf("Write file %s fail: %v ", bridgenf, err) }