Skip to content

Commit

Permalink
set whether the nic is managed by NetworkManager be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
qiutingjun committed Jun 26, 2023
1 parent dc40a8c commit b6379ff
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions charts/templates/ovncni-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -154,6 +156,7 @@ func ParseFlags() *Configuration {
EnableVerboseConnCheck: *argEnableVerboseConnCheck,
TCPConnCheckPort: *argTCPConnectivityCheckPort,
UDPConnCheckPort: *argUDPConnectivityCheckPort,
ManageNicByNetworkManager: *argManageNicByNetworkManager,
}
return config
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b6379ff

Please sign in to comment.