-
Notifications
You must be signed in to change notification settings - Fork 621
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
[octavia-ingress-controller] Add annotations to keep floating IP and/or specify an existing floating IP #2166
Conversation
…ngress.kubernetes.io/floatingip annotations
Welcome @ccleouf66! |
Hi @ccleouf66. 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. |
/easycla |
/ok-to-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.
Some tiny remarks inline.
I wonder if we could have approached this as we do in the controller for Services. There we don't need the keep-ip annotation because we simply check the description of the FIP and in case it's not created by us, we do not delete it.
This would make the cloud provider more consistent, question is - isn't using implicit annotation better?
Thinking about this more now - if we have two separate annotations now ( Then using just IMO that's a strong argument to just implement the I now see that CCM has a [1] cloud-provider-openstack/pkg/openstack/loadbalancer.go Lines 2335 to 2339 in 2231e34
|
Okay thanks for precision ! The use case I have in mind is: when you are running a kube cluster on publuci cloud provider based on openstack like OVH or t-system, the first time when you create your ingress, you don't have yet an existing FIP (except if you created it manually before) so you probably want to let your Cloud provider to create it for you. Now, when you delete your ingress, maybe you want to keep the FIP to not have to recreate DNS record for example and having place the keep annotations can allow you to do that. You probably right, their is a better implementation possible, juste for the moment I don't have it. |
I think that at a minimum I'd add that part about checking if description indicates if FIP was created by Ingress controller before deleting it like it's done in CCM. Then |
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 added a bunch of comments regarding the logic around this. I do not think this should attempt to create a random FIP if user-specified one doesn't exist. If one is attempted to be created it has to request a user-requested address too (even if it's admin API).
… particular one, add additional check if FIP already binded to correct port, add ability to update FIP of an existing ingress by updating annotation
Thanks @dulek, I updated following your comments, let me know if it's ok for you. |
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 logic seems to make sense now, but the code of EnsureFloatingIP()
is structured weirdly. IMO it should:
- Get list of FIPs attached to the VIP port.
- if
needDelete
.- Delete them and return.
- Check if
len(fips) > 1
, return error if so. if existingFloatingIP == ""
:if len(fips) == 1
return success.else
- Create new FIP and save it into
fip
- Create new FIP and save it into
else
:if len(fips) == 1
check if attached FIP has that address and network. If so return success. If not, return error. We might consider if here we shouldn't detach that FIP instead of returning error.else
find FIP by address, check if it's free. If not return error. Save it tofip
.
- Attach
fip
to the VIP port.
…ate mode and improve openstack neutron fip logic
I let you validate and test or need something else ? |
I'm working on #2377 and I think it makes sense to wait until it's merged and then try to sync/reuse the logic in this PR. |
Ok, thanks for update :) |
May we get this merged? I have a scenario where this could be very suitable. |
} | ||
address, err = c.osClient.EnsureFloatingIP(false, lb.VipPortID, floatingIPSetting, c.config.Octavia.FloatingIPNetwork, description) | ||
if err != nil { | ||
return fmt.Errorf("failed to use provided floating IP %s : %v", floatingIPSetting, 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.
is this true? maybe the create floating ip can fail?
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.
You right, the error message is not correct the error don't cover the creation of a new fip.
That is what you are pointing ?
@@ -47,6 +47,33 @@ func (os *OpenStack) getFloatingIPs(listOpts floatingips.ListOpts) ([]floatingip | |||
return allFIPs, nil | |||
} | |||
|
|||
func (os *OpenStack) createFloatingIP(portID string, floatingNetworkID string, description string) (*floatingips.FloatingIP, 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.
cloud-provider-openstack/pkg/openstack/loadbalancer.go
Lines 561 to 581 in 35ff405
func (lbaas *LbaasV2) createFloatingIP(msg string, floatIPOpts floatingips.CreateOpts) (*floatingips.FloatingIP, error) { | |
klog.V(4).Infof("%s floating ip with opts %+v", msg, floatIPOpts) | |
mc := metrics.NewMetricContext("floating_ip", "create") | |
floatIP, err := floatingips.Create(lbaas.network, floatIPOpts).Extract() | |
err = PreserveGopherError(err) | |
if mc.ObserveRequest(err) != nil { | |
return floatIP, fmt.Errorf("error creating LB floatingip: %v", err) | |
} | |
return floatIP, err | |
} | |
func (lbaas *LbaasV2) updateFloatingIP(floatingip *floatingips.FloatingIP, portID *string) (*floatingips.FloatingIP, error) { | |
floatUpdateOpts := floatingips.UpdateOpts{ | |
PortID: portID, | |
} | |
if portID != nil { | |
klog.V(4).Infof("Attaching floating ip %q to loadbalancer port %q", floatingip.FloatingIP, *portID) | |
} else { | |
klog.V(4).Infof("Detaching floating ip %q from port %q", floatingip.FloatingIP, floatingip.PortID) | |
} | |
mc := metrics.NewMetricContext("floating_ip", "update") |
should we reuse those functions?
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'd vote to not reuse them, just because these are separate controllers with separate codepaths and maintaining them through two LB controllers might be cumbersome.
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.
So we duplicate this function and add it in this project ?
I just started with Octavia ingress controller and faced the problem adressed by this issue: use/reuse an externally defined FIP to ensure that a service is exposed with a static address. Any chance to see this feature released soon? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dulek 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 |
What this PR does / why we need it:
Add features:
Which issue this PR fixes(if applicable):
none
Special notes for reviewers:
The doc is also updated to indicated how to.
During the ingress creation only add two annotations inspired from openstack-cloud-controller:
keep-floatingip: default value false
If octavia.ingress.kubernetes.io/floatingip is sepcified and an error occurred (fip not available, not exist, not valid) fallback to create new fip.
Release note: