提交 789610bb 编写于 作者: T Thomas Stromberg

Log warning if br_netfilter cannot be enabled rather than fatally exiting

上级 4cd3c7bd
...@@ -109,6 +109,26 @@ func (r *CRIO) Active() bool { ...@@ -109,6 +109,26 @@ func (r *CRIO) Active() bool {
return r.Init.Active("crio") return r.Init.Active("crio")
} }
// enableIPForwarding configures IP forwarding, which is handled normally by Docker
// Context: https://github.com/kubernetes/kubeadm/issues/1062
func enableIPForwarding(cr CommandRunner) error {
// The bridge-netfilter module enables iptables rules to work on Linux bridges
// NOTE: br_netfilter isn't available in WSL2, but forwarding works fine there anyways
c := exec.Command("sudo", "sysctl", "net.bridge.bridge-nf-call-iptables")
if rr, err := cr.RunCmd(c); err != nil {
klog.Infof("couldn't verify netfilter by %q which might be okay. error: %v", rr.Command(), err)
c = exec.Command("sudo", "modprobe", "br_netfilter")
if _, err := cr.RunCmd(c); err != nil {
klog.Warningf("%q failed, which may be ok: %v", rr.Command(), err)
}
}
c = exec.Command("sudo", "sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward")
if _, err := cr.RunCmd(c); err != nil {
return errors.Wrapf(err, "ip_forward")
}
return nil
}
// Enable idempotently enables CRIO on a host // Enable idempotently enables CRIO on a host
func (r *CRIO) Enable(disOthers, _ bool) error { func (r *CRIO) Enable(disOthers, _ bool) error {
if disOthers { if disOthers {
......
...@@ -22,7 +22,6 @@ import ( ...@@ -22,7 +22,6 @@ import (
"os/exec" "os/exec"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/pkg/errors"
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/command" "k8s.io/minikube/pkg/minikube/command"
...@@ -210,21 +209,3 @@ func disableOthers(me Manager, cr CommandRunner) error { ...@@ -210,21 +209,3 @@ func disableOthers(me Manager, cr CommandRunner) error {
} }
return nil return nil
} }
// enableIPForwarding configures IP forwarding, which is handled normally by Docker
// Context: https://github.com/kubernetes/kubeadm/issues/1062
func enableIPForwarding(cr CommandRunner) error {
c := exec.Command("sudo", "sysctl", "net.bridge.bridge-nf-call-iptables")
if rr, err := cr.RunCmd(c); err != nil {
klog.Infof("couldn't verify netfilter by %q which might be okay. error: %v", rr.Command(), err)
c = exec.Command("sudo", "modprobe", "br_netfilter")
if _, err := cr.RunCmd(c); err != nil {
return errors.Wrapf(err, "br_netfilter")
}
}
c = exec.Command("sudo", "sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward")
if _, err := cr.RunCmd(c); err != nil {
return errors.Wrapf(err, "ip_forward")
}
return nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册