Skip to content

Commit

Permalink
vlan nic support regex
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Jan 19, 2021
1 parent a4042f4 commit 34776b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/vlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ We are working at combine two networks in one cluster.
`wget https://raw.githubusercontent.com/alauda/kube-ovn/release-1.6/dist/images/install.sh`

2. Edit the `install.sh`, modify `NETWORK_TYPE` to `vlan`, `VLAN_INTERFACE_NAME` to related host interface.
> NOTE: if your nodes have different nic name for vlan device you could use regex for VLAN_INTERFACE_NAME or label those nodes with
own `ovn.kubernetes.io/host_interface_name`.

3. Install Kube-OVN

Expand Down
25 changes: 16 additions & 9 deletions pkg/daemon/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,24 @@ func InitVlan(config *Configuration) error {
}

//get host nic name
func (config *Configuration) getInterfaceName() string {
var interfaceName string

func (config *Configuration) getInterfaceName() (ifName string) {
defer func() {
if ifName == "" {
return
}
iface, err := findInterface(ifName)
if err != nil {
klog.Errorf("failed to find iface %s, %v", ifName, err)
ifName = ""
return
}
ifName = iface.Name
}()
node, err := config.KubeClient.CoreV1().Nodes().Get(context.Background(), config.NodeName, metav1.GetOptions{})
if err == nil {
labels := node.GetLabels()
interfaceName = labels[util.HostInterfaceName]
}

if interfaceName != "" {
return interfaceName
if interfaceName := node.GetLabels()[util.HostInterfaceName]; interfaceName != "" {
return interfaceName
}
}

if config.DefaultInterfaceName != "" {
Expand Down

0 comments on commit 34776b8

Please sign in to comment.