Skip to content

Commit

Permalink
Merge pull request #994 from skmatti/split-vips-fix
Browse files Browse the repository at this point in the history
Bugfix: Use Static IP to create forwarding rule when available
  • Loading branch information
k8s-ci-robot authored Jan 16, 2020
2 parents 4f876d5 + b2a4d22 commit 66e133a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/loadbalancers/forwarding_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package loadbalancers

import (
"fmt"

"k8s.io/ingress-gce/pkg/annotations"
"k8s.io/ingress-gce/pkg/composite"
"k8s.io/ingress-gce/pkg/flags"
"k8s.io/ingress-gce/pkg/utils"
Expand Down Expand Up @@ -75,6 +77,22 @@ func (l *L7) checkForwardingRule(name, proxyLink, ip, portRange string) (fw *com
fw = nil
}
if fw == nil {
// This is a special case where exactly one of http or https forwarding rule
// existed before and the existing forwarding rule uses ingress managed static ip address.
// In this case, the forwarding rule needs to be created with the same static ip.
// Note that this is not needed when user specifies a static IP.
if ip == "" {
managedStaticIPName := l.namer.ForwardingRule(namer.HTTPProtocol)
// Get static IP address if ingress has static IP annotation.
// Note that this Static IP annotation is applied by ingress controller.
if currentIPName, exists := l.ingress.Annotations[annotations.StaticIPKey]; exists && currentIPName == managedStaticIPName {
currentIP, _ := l.cloud.GetGlobalAddress(managedStaticIPName)
if currentIP != nil {
klog.V(3).Infof("Ingress managed static IP %s(%s) exists, using it to create forwarding rule %s", currentIPName, currentIP.Address, name)
ip = currentIP.Address
}
}
}
klog.V(3).Infof("Creating forwarding rule for proxy %q and ip %v:%v", proxyLink, ip, portRange)
description, err := l.description()
if err != nil {
Expand Down

0 comments on commit 66e133a

Please sign in to comment.