Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try fix fip not work for default vpc #3666

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pkg/controller/ovn_fip.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,28 @@ func (c *Controller) handleUpdateOvnFip(key string) error {
return err
}
// ovn add fip
if vpcName == c.config.ClusterRouter {
// fix issue https://github.com/kubeovn/kube-ovn/issues/3502
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个注释删掉吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Where ovn fip is not work for default vpc
match := fmt.Sprintf("ip4.src == %s", internalV4Ip)
cm, err := c.configMapsLister.ConfigMaps(c.config.ExternalGatewayConfigNS).Get(util.ExternalGatewayConfig)
if err != nil {
klog.Errorf("failed to create config map %s, %v", util.ExternalGatewayConfig, err)
return err
}
externalGwAddr := cm.Data["external-gw-addr"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里直接拿 eip 的 subnet 的 gw, 不然当多公网时,这个数据就不对了。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if externalGwAddr == "" {
err = fmt.Errorf("external-gw-addr should not be empty in config map %s", util.ExternalGatewayConfig)
klog.Errorf("%v", err)
return err
}

if err = c.OVNNbClient.AddLogicalRouterPolicy(vpcName, util.DefaultVpcFipPolicyPriority, match,
ovnnb.LogicalRouterPolicyActionReroute, []string{externalGwAddr}, nil); err != nil {
klog.Errorf("failed to create LogicalRouterPolicy for fip: %s, %v", fip.Name, err)
return err
}
}
options := map[string]string{"staleless": strconv.FormatBool(c.ExternalGatewayType == kubeovnv1.GWDistributedType)}
if err = c.OVNNbClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip,
internalV4Ip, mac, cachedFip.Spec.IPName, options); err != nil {
Expand Down Expand Up @@ -457,6 +479,12 @@ func (c *Controller) handleDelOvnFip(key string) error {
}
// ovn delete fip nat
if cachedFip.Status.Vpc != "" && cachedFip.Status.V4Eip != "" && cachedFip.Status.V4Ip != "" {
if cachedFip.Status.Vpc == c.config.ClusterRouter {
match := fmt.Sprintf("ip4.src == %s", cachedFip.Status.V4Ip)
zbb88888 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

通过port group和address set同意管理需要出external network的pod的策略路由,不然每多一个fip pod就会多一条规则

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉合理,后面改改

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经改为 port group 管理了

if err = c.OVNNbClient.DeleteLogicalRouterPolicy(cachedFip.Status.Vpc, util.DefaultVpcFipPolicyPriority, match); err != nil {
klog.Errorf("failed to delete LogicalRouterPolicy for fip: %s, %v", cachedFip.Name, err)
}
}
if err = c.OVNNbClient.DeleteNat(cachedFip.Status.Vpc, ovnnb.NATTypeDNATAndSNAT, cachedFip.Status.V4Eip, cachedFip.Status.V4Ip); err != nil {
klog.Errorf("failed to delete fip %s, %v", key, err)
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const (
OvnICPolicyPriority = 29500
NodeRouterPolicyPriority = 30000
NodeLocalDNSPolicyPriority = 30100
DefaultVpcFipPolicyPriority = 30500
SubnetRouterPolicyPriority = 31000

OffloadType = "offload-port"
Expand Down
Loading