diff --git a/addons/flannel/0.24.2/flannel-ethtool.service b/addons/flannel/0.24.2/flannel-ethtool.service new file mode 100644 index 0000000000..b0d5a8ff53 --- /dev/null +++ b/addons/flannel/0.24.2/flannel-ethtool.service @@ -0,0 +1,12 @@ +[Unit] +Description=Disable vxlan checksum offloading for flannel.1 +After=sys-devices-virtual-net-flannel.1.device +Requires=sys-devices-virtual-net-flannel.1.device + +[Service] +Type=oneshot +ExecStart=/sbin/ethtool -K flannel.1 tx-checksum-ip-generic off +RemainAfterExit=yes + +[Install] +WantedBy=sys-devices-virtual-net-flannel.1.device diff --git a/addons/flannel/0.24.2/install.sh b/addons/flannel/0.24.2/install.sh index e8c4930de6..80f7da601a 100644 --- a/addons/flannel/0.24.2/install.sh +++ b/addons/flannel/0.24.2/install.sh @@ -151,10 +151,43 @@ function flannel() { kubectl rollout restart --namespace=kube-flannel daemonset/kube-flannel-ds fi + if flannel_detect_vmware_nic; then + flannel_install_ethtool_service "$src" + fi + flannel_ready_spinner check_network } +function flannel_detect_vmware_nic() { + if lspci -v | grep Ethernet | grep -q "VMware VMXNET3"; then + return 0 + fi + return 1 +} + + +function flannel_install_ethtool_service() { + # this disables the tcp checksum offloading on flannel interface - this is a workaround for + # certain VMWare NICs that use NSX and have a conflict with the way the checksum is handled by + # the kernel. + local src="$1" + + logStep "Installing flannel ethtool service" + logStep "Disabling TCP checksum offloading on flannel interface for VMWare VMXNET3 NICs" + + cp "$src/flannel-ethtool.service" /etc/systemd/system/flannel-ethtool.service + + systemctl daemon-reload + systemctl enable flannel-ethtool.service + if ! timeout 30s systemctl start flannel-ethtool.service; then + log "Failed to start flannel-ethtool.service within 30s, restarting it" + systemctl restart flannel-ethtool.service + fi + + logSuccess "Flannel ethtool service installed" +} + function flannel_init_pod_subnet() { POD_CIDR="$FLANNEL_POD_CIDR" POD_CIDR_RANGE="$FLANNEL_POD_CIDR_RANGE" diff --git a/addons/flannel/template/base/install.sh b/addons/flannel/template/base/install.sh index 63dfa4a509..5d04926fa1 100644 --- a/addons/flannel/template/base/install.sh +++ b/addons/flannel/template/base/install.sh @@ -160,16 +160,12 @@ function flannel() { } function flannel_detect_vmware_nic() { - local vmxnet3=false - if lspci -v | grep Ethernet | grep -q "VMware VMXNET3"; then - vmxnet3=true + return 0 fi - - return $vmxnet3 + return 1 } - function flannel_install_ethtool_service() { # this disables the tcp checksum offloading on flannel interface - this is a workaround for # certain VMWare NICs that use NSX and have a conflict with the way the checksum is handled by @@ -177,6 +173,7 @@ function flannel_install_ethtool_service() { local src="$1" logStep "Installing flannel ethtool service" + logStep "Disabling TCP checksum offloading on flannel interface for VMWare VMXNET3 NICs" cp "$src/flannel-ethtool.service" /etc/systemd/system/flannel-ethtool.service