Skip to content

Commit

Permalink
1.Support to specify node nic name
Browse files Browse the repository at this point in the history
2.Delete extra blank lines

(cherry picked from commit eb38742)
  • Loading branch information
active-xu authored and oilbeater committed Jun 11, 2021
1 parent 8c37d4b commit 1f48f9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package daemon

import (
"context"
"errors"
"flag"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -108,11 +110,11 @@ func ParseFlags() (*Configuration, error) {
DefaultInterfaceName: *argsDefaultInterfaceName,
}

if err := config.initNicConfig(); err != nil {
if err := config.initKubeClient(); err != nil {
return nil, err
}

if err := config.initKubeClient(); err != nil {
if err := config.initNicConfig(); err != nil {
return nil, err
}

Expand All @@ -127,6 +129,17 @@ func (config *Configuration) initNicConfig() error {
encapIP string
)

//Support to specify node network card separately
node, err := config.KubeClient.CoreV1().Nodes().Get(context.Background(), config.NodeName, metav1.GetOptions{})
if err != nil {
klog.Errorf("Failed to find node info, err: %v", err)
return err
}
if nodeTunnelName := node.GetAnnotations()[util.TunnelInterfaceAnnotation]; nodeTunnelName != "" {
config.Iface = nodeTunnelName
klog.Infof("Find node tunnel interface name: %v", nodeTunnelName)
}

if config.Iface == "" {
podIP, ok := os.LookupEnv("POD_IP")
if !ok || podIP == "" {
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const (
PortNameAnnotation = "ovn.kubernetes.io/port_name"
LogicalSwitchAnnotation = "ovn.kubernetes.io/logical_switch"

TunnelInterfaceAnnotation = "ovn.kubernetes.io/tunnel_interface"

SubnetNameLabel = "ovn.kubernetes.io/subnet"
ICGatewayLabel = "ovn.kubernetes.io/ic-gw"
ExGatewayLabel = "ovn.kubernetes.io/external-gw"
Expand Down

0 comments on commit 1f48f9f

Please sign in to comment.