Skip to content

Commit

Permalink
add svc cidr in ovs LB for optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 committed Jan 4, 2022
1 parent fe2fc31 commit 8974f6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func (c *Controller) InitOVN() error {
klog.Errorf("init load balancer failed: %v", err)
return err
}
v4Svc, _ := util.SplitStringIP(c.config.ServiceClusterIPRange)
if v4Svc != "" {
if err := c.ovnClient.SetLBCIDR(v4Svc); err != nil {
klog.Errorf("init load balancer svc cidr failed: %v", err)
return err
}
}
}

if err := c.initDefaultVlan(); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1939,3 +1939,10 @@ func (c *Client) AclExists(priority, direction string) (bool, error) {
}
return true, nil
}

func (c *Client) SetLBCIDR(svccidr string) error {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", fmt.Sprintf("options:svc_ipv4_cidr=%s", svccidr)); err != nil {
return fmt.Errorf("failed to set svc cidr for lb, %v", err)
}
return nil
}

0 comments on commit 8974f6a

Please sign in to comment.