Skip to content

CP/DP Split: Add ability to set loadBalancerClass for load balancer Service #3319

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apis/v1alpha2/nginxproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ type ServiceSpec struct {
// +optional
LoadBalancerIP *string `json:"loadBalancerIP,omitempty"`

// LoadBalancerClass is the class of the load balancer implementation this Service belongs to.
// Requires service type to be LoadBalancer.
//
// +optional
LoadBalancerClass *string `json:"loadBalancerClass,omitempty"`

// Annotations contain any Service-specific annotations.
//
// +optional
Expand Down
5 changes: 5 additions & 0 deletions apis/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions charts/nginx-gateway-fabric/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ nginx:
# -- The static IP address for the load balancer. Requires nginx.service.type set to LoadBalancer.
# loadBalancerIP: ""

# -- LoadBalancerClass is the class of the load balancer implementation this Service belongs to.
# Requires nginx.service.type set to LoadBalancer.
# loadBalancerClass: ""

# -- The IP ranges (CIDR) that are allowed to access the load balancer. Requires nginx.service.type set to LoadBalancer.
# loadBalancerSourceRanges: []

Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/gateway.nginx.org_nginxproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,11 @@ spec:
- Cluster
- Local
type: string
loadBalancerClass:
description: |-
LoadBalancerClass is the class of the load balancer implementation this Service belongs to.
Requires service type to be LoadBalancer.
type: string
loadBalancerIP:
description: LoadBalancerIP is a static IP address for the
load balancer. Requires service type to be LoadBalancer.
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,11 @@ spec:
- Cluster
- Local
type: string
loadBalancerClass:
description: |-
LoadBalancerClass is the class of the load balancer implementation this Service belongs to.
Requires service type to be LoadBalancer.
type: string
loadBalancerIP:
description: LoadBalancerIP is a static IP address for the
load balancer. Requires service type to be LoadBalancer.
Expand Down
3 changes: 3 additions & 0 deletions internal/mode/static/provisioner/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ func buildNginxService(
if serviceCfg.LoadBalancerIP != nil {
svc.Spec.LoadBalancerIP = *serviceCfg.LoadBalancerIP
}
if serviceCfg.LoadBalancerClass != nil {
svc.Spec.LoadBalancerClass = serviceCfg.LoadBalancerClass
}
if serviceCfg.LoadBalancerSourceRanges != nil {
svc.Spec.LoadBalancerSourceRanges = serviceCfg.LoadBalancerSourceRanges
}
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/provisioner/objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
ServiceType: helpers.GetPointer(ngfAPIv1alpha2.ServiceTypeNodePort),
ExternalTrafficPolicy: helpers.GetPointer(ngfAPIv1alpha2.ExternalTrafficPolicyCluster),
LoadBalancerIP: helpers.GetPointer("1.2.3.4"),
LoadBalancerClass: helpers.GetPointer("myLoadBalancerClass"),
LoadBalancerSourceRanges: []string{"5.6.7.8"},
},
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
Expand Down Expand Up @@ -299,6 +300,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
g.Expect(svc.Spec.Type).To(Equal(corev1.ServiceTypeNodePort))
g.Expect(svc.Spec.ExternalTrafficPolicy).To(Equal(corev1.ServiceExternalTrafficPolicyTypeCluster))
g.Expect(svc.Spec.LoadBalancerIP).To(Equal("1.2.3.4"))
g.Expect(*svc.Spec.LoadBalancerClass).To(Equal("myLoadBalancerClass"))
g.Expect(svc.Spec.LoadBalancerSourceRanges).To(Equal([]string{"5.6.7.8"}))

depObj := objects[5]
Expand Down
Loading