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

Cherry Pick #906 (Fix ILB forwarding rule bug) to release-1.7 #907

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions pkg/loadbalancers/features/l7ilb.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ func isSameNetwork(l, r string) (bool, error) {
return lID.Equal(rID), nil
}

// IsCustomModeNetwork is a helper for determining if a network is a custom mode network
// (as opposed to a auto mode network). This is used for l7-ilb since custom mode networks
// require an additional field on the forwarding rule
func IsCustomModeNetwork(c *gce.Cloud, networkURL string) (bool, error) {
netID, err := cloud.ParseResourceURL(networkURL)
if err != nil {
return false, err
}

network, err := c.Compute().Networks().Get(context.Background(), netID.Key)
if err != nil {
return false, err
}

return !network.AutoCreateSubnetworks, nil
}

// L7ILBVersion is a helper to get the version of L7-ILB
func L7ILBVersions() *ResourceVersions {
return versionsFromFeatures([]string{FeatureL7ILB})
Expand Down
13 changes: 12 additions & 1 deletion pkg/loadbalancers/forwarding_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ package loadbalancers

import (
"fmt"

"k8s.io/ingress-gce/pkg/composite"
"k8s.io/ingress-gce/pkg/flags"
"k8s.io/ingress-gce/pkg/loadbalancers/features"
"k8s.io/ingress-gce/pkg/utils"
"k8s.io/klog"
)
Expand Down Expand Up @@ -89,9 +92,17 @@ func (l *L7) checkForwardingRule(name, proxyLink, ip, portRange string) (fw *com
}

// Update rule for L7-ILB
if utils.IsGCEL7ILBIngress(l.runtimeInfo.Ingress) {
if flags.F.EnableL7Ilb && utils.IsGCEL7ILBIngress(l.runtimeInfo.Ingress) {
rule.LoadBalancingScheme = "INTERNAL_MANAGED"

// Custom mode networks require adding the cluster subnetwork
if isCustomMode, err := features.IsCustomModeNetwork(l.cloud, l.cloud.NetworkURL()); err != nil {
return nil, err
} else if isCustomMode {
rule.Subnetwork = l.cloud.SubnetworkURL()
}
}

if err = composite.CreateForwardingRule(l.cloud, key, rule); err != nil {
return nil, err
}
Expand Down