-
Notifications
You must be signed in to change notification settings - Fork 303
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
Implement support for Internal/Regional Static IP for L7-ILB #1174
Implement support for Internal/Regional Static IP for L7-ILB #1174
Conversation
Hi @spencerhance. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
8a134d5
to
d5344ec
Compare
d5344ec
to
1f8daf7
Compare
Rebased since #1173 has merged. The tests should pass now. |
1f8daf7
to
3d6d0e3
Compare
"k8s.io/ingress-gce/pkg/flags" | ||
"k8s.io/ingress-gce/pkg/utils" | ||
"k8s.io/ingress-gce/pkg/utils/namer" | ||
"k8s.io/klog" | ||
) | ||
|
||
// checkStaticIP reserves a static IP allocated to the Forwarding Rule. | ||
// checkStaticIP reserves a regional or global static IP allocated to the Forwarding Rule. | ||
func (l *L7) checkStaticIP() (err error) { |
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.
test?
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.
func TestCreateHTTPILBLoadBalancerStaticIp(t *testing.T) { |
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.
The tests for checkStaticIP() are sort of included in loadbalancers_test.go right now since it also creates/gets resources from the GCE API, and piggybacks off of those mocks
globalIp := ing.GlobalStaticIPName() | ||
regionalIp := ing.RegionalStaticIPName() | ||
|
||
if globalIp != "" && regionalIp != "" { |
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.
I guess you need to validate if this is a L7 ILB then just return regionalStaticIP and ignore GlobalStaticIP?
vice versa for L7 XLB?
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.
True, but I wanted to have a check for if the user specified both by accident
return "", false, fmt.Errorf("the given static IP name %v doesn't translate to an existing global static IP.", | ||
// TODO(shance): Replace version | ||
if ip, err := composite.GetAddress(l.cloud, key, meta.VersionGA); err != nil || ip == nil { | ||
return "", false, fmt.Errorf("The given static IP name %v doesn't translate to an existing static IP.", |
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.
lower case for the initial character for error
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
@@ -163,10 +163,16 @@ func (l *L7) getEffectiveIP() (string, bool, error) { | |||
// TODO: Handle the last case better. | |||
|
|||
if l.runtimeInfo.StaticIPName != "" { | |||
key, err := l.CreateKey(l.runtimeInfo.StaticIPName) |
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.
don't you need to handle the L7 ILB for this case as well?
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.
oh I see. CreateKey
handles it already.
pkg/loadbalancers/addresses.go
Outdated
if ip == nil { | ||
klog.V(3).Infof("Creating static ip %v", managedStaticIPName) | ||
err = l.cloud.ReserveGlobalAddress(&compute.Address{Name: managedStaticIPName, Address: l.fw.IPAddress}) | ||
address := &composite.Address{Name: managedStaticIPName, Address: l.fw.IPAddress, Version: meta.VersionGA} |
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.
Probably worth having a l.newStaticAddress()
function to output a composite.Address based on the L7 config.
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.
Hm, I'm hesitant to split this out into a function since it's fairly short and we only use it once
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.
having a separate function makes this a bit more self contained. Which means the special handling for ILB is invisible to the main flow.
if isInternal {
// Used for L7 ILB
address.AddressType = "INTERNAL"
}
Next time when changes are needed, it can just piggy back to the new function and do not touch the main flow.
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.
Okay done, also added a unit test
This is done via a regional-static-ip annotation on the ingress
3d6d0e3
to
d6080dd
Compare
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, spencerhance The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Cherry pick #1174 [Implement support for Internal/Regional Static IP for L7-ILB] into release-1.9
This is implemented via an annotation "kubernetes.io/ingress.regional-static-ip-name". This uses the same prefix as the existing annotation, "global-static-ip-name."
This PR also depends on the update of k8s-cloud-provider in #1173