Skip to content

Conversation

@puertomontt
Copy link
Contributor

@puertomontt puertomontt commented Dec 8, 2025

Description

Motivation:
Users want to be able to set IP of the LoadBalancer Service for a gateway. Gateway API provides Gateway.spec.addresses for this.

Changes:
Use the first Gateway.spec.addresses of type IP to set the loadbalancerIP field of the Service.
Note that although this field is deprecated it is not going to be removed. See here for a good write-up.

Change Type

/kind feature

Changelog

Support Gateway.spec.addresses. We currently support one IP address type value that will be used in the gateway's Service loadbalancerIP.

Additional Notes

Did not add conformance testing as it depends on setting status which we currently don't have a good way to do from the deployer.

Copilot AI review requested due to automatic review settings December 8, 2025 21:24
@gateway-bot gateway-bot added do-not-merge/description-invalid do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/description-invalid labels Dec 8, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for setting the LoadBalancer service IP from Gateway.spec.addresses in the Gateway API. When a Gateway specifies an IP address in its spec, and the service type is LoadBalancer, the implementation extracts this IP and sets it as the loadBalancerIP field in the generated Kubernetes Service resource.

Key Changes

  • Gateway address extraction: New extractLoadBalancerIP function validates and extracts the first valid IP address from Gateway.spec.addresses where the type is IPAddressType (or nil, which defaults to IPAddressType per Gateway API spec)
  • Service generation: Modified GetServiceValues to accept an optional loadBalancerIP parameter and added the field to the HelmService struct
  • Helm template updates: Updated both envoy and agentgateway service templates to conditionally render the loadBalancerIP field

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/kgateway/deployer/gateway_parameters.go Added extractLoadBalancerIP function with IP validation using netip.ParseAddr, and integrated it into the values generation flow for LoadBalancer-type services
pkg/deployer/values_helpers.go Updated GetServiceValues signature to accept loadBalancerIP parameter and refactored to safely handle nil svcConfig
pkg/deployer/values.go Added LoadBalancerIP field to HelmService struct with json omitempty tag
pkg/kgateway/helm/envoy/templates/service.yaml Added conditional rendering of loadBalancerIP field using Helm with directive
pkg/kgateway/helm/agentgateway/templates/service.yaml Added conditional rendering of loadBalancerIP field using Helm with directive
test/deployer/testdata/loadbalancer-static-ip.yaml New test input with Gateway specifying a static IP address (203.0.113.10) in spec.addresses
test/deployer/testdata/loadbalancer-static-ip-out.yaml Expected Helm output showing the loadBalancerIP field properly set in the generated Service manifest

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gateway-bot gateway-bot added release-note and removed do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 8, 2025
Signed-off-by: omar <[email protected]>
Copy link
Member

@timflannagan timflannagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also enable the conformance test that backs this type of functionality?

Signed-off-by: omar <[email protected]>
@puertomontt
Copy link
Contributor Author

@timflannagan see "Additional Notes"

@dmitri-d
Copy link
Contributor

lgtm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// SetLoadBalancerIPFromGateway extracts the IP address from Gateway.spec.addresses
// and sets it on the HelmService if the service type is LoadBalancer.
// Only sets the IP if exactly one valid IP address is found in Gateway.spec.addresses.
// Returns an error if more than one address is specified or no valid IP address is found.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function documentation is incomplete. It states that an error is returned "if more than one address is specified or no valid IP address is found", but it doesn't clarify what happens when a single address of a non-IP type (e.g., HostnameAddressType) is provided. The current implementation returns ErrNoValidIPAddress in this case. Consider updating the documentation to explicitly state: "Returns an error if more than one address is specified, if the single address is not of type IPAddress, or if the IP address value is invalid."

Suggested change
// Returns an error if more than one address is specified or no valid IP address is found.
// Returns an error if more than one address is specified, if the single address is not of type IPAddress,
// or if the IP address value is invalid.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@sheidkamp sheidkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes, definitely cleaner.

Signed-off-by: omar <[email protected]>
@puertomontt puertomontt added this pull request to the merge queue Dec 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 12, 2025
@puertomontt puertomontt added this pull request to the merge queue Dec 12, 2025
Merged via the queue into kgateway-dev:main with commit 630e261 Dec 12, 2025
29 checks passed
@puertomontt puertomontt deleted the lbip branch December 12, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GatewaySpec.addresses is ignored, static IP not respected in GKE

5 participants