Skip to content

Commit

Permalink
Merge pull request #9932 from kubernetes/br_netfilter2
Browse files Browse the repository at this point in the history
wsl2: log warning if br_netfilter cannot be enabled rather than fatally exit
  • Loading branch information
tstromberg authored Dec 11, 2020
2 parents 947749a + 789610b commit a60e264
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
20 changes: 20 additions & 0 deletions pkg/minikube/cruntime/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ func (r *CRIO) Active() bool {
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
func (r *CRIO) Enable(disOthers, _ bool) error {
if disOthers {
Expand Down
19 changes: 0 additions & 19 deletions pkg/minikube/cruntime/cruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"os/exec"

"github.com/blang/semver"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/command"
Expand Down Expand Up @@ -210,21 +209,3 @@ func disableOthers(me Manager, cr CommandRunner) error {
}
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
}

0 comments on commit a60e264

Please sign in to comment.