-
Notifications
You must be signed in to change notification settings - Fork 456
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
// 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"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里直接拿 eip 的 subnet 的 gw, 不然当多公网时,这个数据就不对了。 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 通过port group和address set同意管理需要出external network的pod的策略路由,不然每多一个fip pod就会多一条规则 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 感觉合理,后面改改 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个注释删掉吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done