diff --git a/charts/templates/ovncni-ds.yaml b/charts/templates/ovncni-ds.yaml index 50e429a55bb2..9533ecf99a4b 100644 --- a/charts/templates/ovncni-ds.yaml +++ b/charts/templates/ovncni-ds.yaml @@ -78,6 +78,7 @@ spec: - --log_file_max_size=0 - --enable-metrics={{- .Values.networking.ENABLE_METRICS }} - --kubelet-dir={{ .Values.kubelet_conf.KUBELET_DIR }} + - --manage-nic-by-network-manager={{ .Values.networking.MANAGE-NIC-BY-NETWORK-MANAGER }} securityContext: runAsUser: 0 privileged: true diff --git a/charts/values.yaml b/charts/values.yaml index f6a1cce7b2f8..b90fd99b47e4 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -47,6 +47,7 @@ networking: ENABLE_ECMP: false ENABLE_METRICS: true NODE_LOCAL_DNS_IP: "" + MANAGE-NIC-BY-NETWORK-MANAGER: false func: ENABLE_LB: true diff --git a/dist/images/install.sh b/dist/images/install.sh index 0c4dfd36f2ba..bd780bb15c83 100755 --- a/dist/images/install.sh +++ b/dist/images/install.sh @@ -37,6 +37,7 @@ ENABLE_BIND_LOCAL_IP=${ENABLE_BIND_LOCAL_IP:-true} DEBUG_WRAPPER=${DEBUG_WRAPPER:-} KUBELET_DIR=${KUBELET_DIR:-/var/lib/kubelet} +MANAGE_NIC_BY_NETWORK_MANAGER=${MANAGE_NIC_BY_NETWORK_MANAGER:-false} CNI_CONF_DIR="/etc/cni/net.d" CNI_BIN_DIR="/opt/cni/bin" @@ -4401,6 +4402,7 @@ spec: - --log_file=/var/log/kube-ovn/kube-ovn-cni.log - --log_file_max_size=0 - --kubelet-dir=$KUBELET_DIR + - --manage-nic-by-network-manager=$MANAGE_NIC_BY_NETWORK_MANAGER securityContext: runAsUser: 0 privileged: true diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index 982df611696c..c80d259d3a85 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -63,6 +63,7 @@ type Configuration struct { EnableVerboseConnCheck bool TCPConnCheckPort int UDPConnCheckPort int + ManageNicByNetworkManager bool } // ParseFlags will parse cmd args then init kubeClient and configuration @@ -100,6 +101,7 @@ func ParseFlags() *Configuration { argEnableVerboseConnCheck = pflag.Bool("enable-verbose-conn-check", false, "enable TCP/UDP connectivity check listen port") argTCPConnectivityCheckPort = pflag.Int("tcp-conn-check-port", 8100, "TCP connectivity Check Port") argUDPConnectivityCheckPort = pflag.Int("udp-conn-check-port", 8101, "UDP connectivity Check Port") + argManageNicByNetworkManager = pflag.Bool("manage-nic-by-network-manager", false, "set nic link managed by NetworkManager") ) // mute info log for ipset lib @@ -154,6 +156,7 @@ func ParseFlags() *Configuration { EnableVerboseConnCheck: *argEnableVerboseConnCheck, TCPConnCheckPort: *argTCPConnectivityCheckPort, UDPConnCheckPort: *argUDPConnectivityCheckPort, + ManageNicByNetworkManager: *argManageNicByNetworkManager, } return config } diff --git a/pkg/daemon/init_linux.go b/pkg/daemon/init_linux.go index d6f55be79d04..0fc3ada8b29b 100644 --- a/pkg/daemon/init_linux.go +++ b/pkg/daemon/init_linux.go @@ -76,7 +76,7 @@ func (c *Controller) changeProvideNicName(current, target string) (bool, error) } // set link unmanaged by NetworkManager - if err = c.nmSyncer.SetManaged(current, false); err != nil { + if err = c.nmSyncer.SetManaged(current, c.config.ManageNicByNetworkManager); err != nil { klog.Errorf("failed to set device %s unmanaged by NetworkManager: %v", current, err) return false, err } diff --git a/pkg/daemon/ovs_linux.go b/pkg/daemon/ovs_linux.go index aec58949d8eb..f3dccd9fc0d1 100644 --- a/pkg/daemon/ovs_linux.go +++ b/pkg/daemon/ovs_linux.go @@ -928,10 +928,11 @@ func (c *Controller) transferAddrsAndRoutes(nicName, brName string, delNonExiste } // set link unmanaged by NetworkManager - if err = c.nmSyncer.SetManaged(nicName, false); err != nil { + if err = c.nmSyncer.SetManaged(nicName, c.config.ManageNicByNetworkManager); err != nil { klog.Errorf("failed to set device %s unmanaged by NetworkManager: %v", nicName, err) return 0, err } + if err = c.nmSyncer.AddDevice(nicName, brName); err != nil { klog.Errorf("failed to monitor NetworkManager event for device %s: %v", nicName, err) return 0, err