From 22bd3a3ce79c953a5891b1b34038c535ec5acf60 Mon Sep 17 00:00:00 2001 From: William Zhang Date: Thu, 18 Apr 2019 09:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20nf=5Fconntrack=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: William Zhang --- README.md | 4 +--- k3s.service | 4 ++-- pkg/agent/syssetup/setup.go | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0b74f59713..3705448bff 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ flag At this point, you can run the agent as a separate process or not run it on this node at all. If you encounter an error like `"stream server error: listen tcp: lookup some-host on X.X.X.X:53: no such host"` -when starting k3s please ensure `/etc/hosts` contains your current hostname (output of `hostname`), +when starting k3s please ensure `/etc/hosts` contains your current hostname (output of `hostname`), set to a 127.x.x.x address. For example: ``` 127.0.1.1 myhost @@ -267,8 +267,6 @@ After=network.target [Service] Type=notify EnvironmentFile=/etc/systemd/system/k3s.service.env -ExecStartPre=-/sbin/modprobe br_netfilter -ExecStartPre=-/sbin/modprobe overlay ExecStart=/usr/local/bin/k3s server KillMode=process Delegate=yes diff --git a/k3s.service b/k3s.service index c30850295c..12017aec5d 100644 --- a/k3s.service +++ b/k3s.service @@ -4,8 +4,8 @@ Documentation=https://k3s.io After=network.target [Service] -ExecStartPre=-/sbin/modprobe br_netfilter -ExecStartPre=-/sbin/modprobe overlay +Type=notify +EnvironmentFile=/etc/systemd/system/k3s.service.env ExecStart=/usr/local/bin/k3s server KillMode=process Delegate=yes diff --git a/pkg/agent/syssetup/setup.go b/pkg/agent/syssetup/setup.go index 7f32479034..ededacf01d 100644 --- a/pkg/agent/syssetup/setup.go +++ b/pkg/agent/syssetup/setup.go @@ -13,12 +13,26 @@ var ( ) func Configure() error { - exec.Command("modprobe", "br_netfilter").Run() + if err := exec.Command("modprobe", "br_netfilter").Run(); err != nil { + logrus.Warnf("failed to start br_netfilter module") + return nil + } if err := ioutil.WriteFile(callIPTablesFile, []byte("1"), 0640); err != nil { logrus.Warnf("failed to write value 1 at %s: %v", callIPTablesFile, err) + return nil } if err := ioutil.WriteFile(forward, []byte("1"), 0640); err != nil { logrus.Warnf("failed to write value 1 at %s: %v", forward, err) + return nil + } + + if err := exec.Command("modprobe", "overlay").Run(); err != nil { + logrus.Warnf("failed to start overlay module") + return nil + } + if err := exec.Command("modprobe", "nf_conntrack").Run(); err != nil { + logrus.Warnf("failed to start nf_conntrack module") + return nil } return nil }