cluster-api-provider-gcp icon indicating copy to clipboard operation
cluster-api-provider-gcp copied to clipboard

Add support for creating an internal load balancer with predefined IP address

Open RnkeZ opened this issue 6 months ago • 20 comments
trafficstars

What type of PR is this?

/kind feature

What this PR does / why we need it: When deploying a cluster, it is useful to know the static IP of the API server before the internal passthrough load balancer is created, especially for integration with certain third-party tools. This setup is similar to how private IPs are handled in other CAPI providers (such as CAPZ), where users can predefine the private IP of the load balancer.

Which issue(s) this PR fixes: Fixes #1474

Release note:

Add an option to create a predefined static IP address for an internal passthrough load balancer.

RnkeZ avatar May 12 '25 12:05 RnkeZ

Deploy Preview for kubernetes-sigs-cluster-api-gcp ready!

Name Link
Latest commit 3121cf8ae7f546fc8d6c6d5e00a682b74d9856cd
Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-gcp/deploys/68467f7e5a513c0009705e0c
Deploy Preview https://deploy-preview-1475--kubernetes-sigs-cluster-api-gcp.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar May 12 '25 12:05 netlify[bot]

Welcome @RnkeZ!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-gcp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-gcp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar May 12 '25 12:05 k8s-ci-robot

Hi @RnkeZ. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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-sigs/prow repository.

k8s-ci-robot avatar May 12 '25 12:05 k8s-ci-robot

/ok-to-test

salasberryfin avatar May 16 '25 09:05 salasberryfin

/assign @barbacbd

for a review

damdo avatar May 16 '25 10:05 damdo

@damdo: GitHub didn't allow me to assign the following users: barbacbd.

Note that only kubernetes-sigs members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. For more information please see the contributor guide

In response to this:

/assign @barbacbd

for a review

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-sigs/prow repository.

k8s-ci-robot avatar May 16 '25 10:05 k8s-ci-robot

/cc @nrb

As you may be interested wrt the internal load balancer

damdo avatar Jun 05 '25 12:06 damdo

@RnkeZ Thank you for all of the work you have put into the PR so far. I am interested in using this feature.

Since the IPAddress is a new field, the tests need to be updated to ensure this change works and doesn't get disturbed by a future change.

cloud/services/compute/loadbalancers/reconcile_test.go

I submitted a PR to your fork with the tests.

swarren83 avatar Jun 05 '25 18:06 swarren83

@RnkeZ Looks like I added a blank line where the linter doesn't want one. All that needs to be done is to delete that blank line at 616.

Error: cloud/services/compute/loadbalancers/reconcile_test.go:616:1: File is not properly formatted (gofmt)

swarren83 avatar Jun 06 '25 16:06 swarren83

It also looks like test static_address_set_for_internal_load_balancer is not properly configured or the code isn't properly setting the static address.

From what I can tell, s.internaladdresses = tt.mockAddress doesn't like the fact that a static address is configured via s.GCPCluster.Spec.LoadBalancer.InternalLoadBalancer.IPAddress = ptr.To("1.2.3.4")

I wonder if the static address needs to be set in Objects: map[meta.Key]*cloud.MockAddressesObj{},

swarren83 avatar Jun 06 '25 16:06 swarren83

I will work on fixing the tests and submit a new PR to your branch @RnkeZ

swarren83 avatar Jun 06 '25 16:06 swarren83

Okay, I'm away from my PC atm, however, if it means anything, we've had this feature running in production for the last few weeks, and it works as expected. We had to build our own image as it was pretty urgent to get it up and running.

RnkeZ avatar Jun 06 '25 16:06 RnkeZ

The failures are due to the tests. I will get them fixed and send you a new PR.

swarren83 avatar Jun 06 '25 18:06 swarren83

@RnkeZ I fixed the test in this PR. Please review and merge at your leisure.

swarren83 avatar Jun 06 '25 20:06 swarren83

@barbacbd @damdo Is there anything else that needs to be done for approval?

swarren83 avatar Jun 09 '25 13:06 swarren83

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, RnkeZ

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Jun 09 '25 13:06 k8s-ci-robot

@damdo I hope your are doing well. Do you have some time to spare to review this PR?

I am looking to use this by August.

swarren83 avatar Jun 12 '25 13:06 swarren83

Hey @swarren83 I am away on PTO until next week. Maybe @barbacbd and @salasberryfin or @richardcase can take a look

damdo avatar Jun 12 '25 14:06 damdo

Enjoy your time off!

swarren83 avatar Jun 12 '25 14:06 swarren83

Is this feat going to be scheduled in a Milestone for release? If so when will it get released?

swarren83 avatar Jun 18 '25 14:06 swarren83

Unfortunately, it looks like we missed the release window since we didn't get a second approval.

RnkeZ avatar Jun 30 '25 08:06 RnkeZ

Hey @damdo, could you please check this now?

RnkeZ avatar Jul 14 '25 06:07 RnkeZ

Dam asked me to take a look at this. From a high level, I don't see anything wrong with this request or this approach.

/lgtm

nrb avatar Jul 17 '25 16:07 nrb

Thanks @nrb

/unhold

damdo avatar Jul 17 '25 16:07 damdo