Skip to content

feat(provisioner): ContourDeployment loadBalancerSourceRanges and loadBalancerClass - #7665

Open
VedantMadane wants to merge 3 commits into
projectcontour:mainfrom
VedantMadane:feat/contourdeployment-lb-source-ranges-class-7334
Open

feat(provisioner): ContourDeployment loadBalancerSourceRanges and loadBalancerClass#7665
VedantMadane wants to merge 3 commits into
projectcontour:mainfrom
VedantMadane:feat/contourdeployment-lb-source-ranges-class-7334

Conversation

@VedantMadane

Copy link
Copy Markdown

Summary

Adds loadBalancerSourceRanges and loadBalancerClass to ContourDeployment.spec.envoy.networkPublishing so the Gateway provisioner can set the corresponding Envoy Service fields when publishing as a LoadBalancer.

Fixes #7334

Motivation

When using Contour Gateway Provisioner with a custom ContourDeployment, there was no way to configure:

  • Service.spec.loadBalancerSourceRanges (restrict source IPs)
  • Service.spec.loadBalancerClass (select LB implementation)

Changes

  1. API (ContourDeployment / NetworkPublishing): new optional fields
  2. Provisioner model + gateway controller: plumb fields from ContourDeployment params
  3. Envoy Service: set fields when publishing type is LoadBalancerService
  4. Equality: detect changes to reconcile those fields
  5. CRDs / examples: regenerated-style updates for the new schema
  6. Unit test: TestDesiredEnvoyServiceLoadBalancerFields

Example

apiVersion: projectcontour.io/v1alpha1
kind: ContourDeployment
metadata:
  name: contour
spec:
  envoy:
    networkPublishing:
      type: LoadBalancerService
      loadBalancerSourceRanges:
        - 10.0.0.0/8
      loadBalancerClass: service.k8s.aws/nlb

@VedantMadane
VedantMadane requested a review from a team as a code owner August 9, 2026 15:15
@VedantMadane
VedantMadane requested review from sunjayBhatia and tsaarni and removed request for a team August 9, 2026 15:15
@tsaarni tsaarni added the release-note/small A small change that needs one line of explanation in the release notes. label Aug 18, 2026
…lass on ContourDeployment

Allow ContourDeployment.spec.envoy.networkPublishing to configure the
Envoy Service LoadBalancer fields Service.spec.loadBalancerSourceRanges
and Service.spec.loadBalancerClass so Gateway provisioner users can
restrict source IPs and select a load balancer implementation.

Fixes projectcontour#7334

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Add unreleased changelog for projectcontour#7665 and regenerate CRDs, example
manifests, and API reference docs so check-generate passes.

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
@VedantMadane
VedantMadane force-pushed the feat/contourdeployment-lb-source-ranges-class-7334 branch from 1b726e3 to 96edf5e Compare August 18, 2026 15:39
VedantMadane added a commit to VedantMadane/contour that referenced this pull request Aug 18, 2026
Add unreleased changelog for projectcontour#7665 and regenerate CRDs, example
manifests, and API reference docs so check-generate passes.

Signed-off-by: Vedant Madane <vedantnm@gmail.com>
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.37%. Comparing base (fdb28b9) to head (74297e0).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7665      +/-   ##
==========================================
+ Coverage   82.35%   82.37%   +0.01%     
==========================================
  Files         131      131              
  Lines       15915    15930      +15     
==========================================
+ Hits        13107    13122      +15     
  Misses       2520     2520              
  Partials      288      288              
Files with missing lines Coverage Δ
internal/provisioner/controller/gateway.go 60.42% <100.00%> (+0.68%) ⬆️
internal/provisioner/equality/equality.go 56.85% <100.00%> (+1.35%) ⬆️
internal/provisioner/model/model.go 100.00% <ø> (ø)
internal/provisioner/objects/service/service.go 75.80% <100.00%> (+0.66%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add unit coverage for ContourDeployment networkPublishing LB fields
through equality change detection, DesiredEnvoyService (LB and
ClusterIP ignore paths), and gateway controller copy into the Envoy
Service. Improves codecov/patch on the ContourDeployment LB feature.

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
@VedantMadane
VedantMadane force-pushed the feat/contourdeployment-lb-source-ranges-class-7334 branch from 42fb60a to 74297e0 Compare August 22, 2026 13:23
@sufiyanpk7

Copy link
Copy Markdown

When will this go live? I’m not sure why the LoadBalancer class is restricting us. It’s forcing us to move away from Contour and use Envoy Gateway instead, in the VMware ecosystem :(

Comment on lines +195 to +199
if !apiequality.Semantic.DeepEqual(current.Spec.LoadBalancerClass, expected.Spec.LoadBalancerClass) {
updated.Spec.LoadBalancerClass = expected.Spec.LoadBalancerClass
changed = true
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The comment on LoadBalancerClass says (link)

This field can only be set when creating or updating a Service to type 'LoadBalancer'. Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type.

So since we cannot update this, the inequality should be ignored, or what do you think?

Comment on lines +312 to +317
if len(networkPublishing.LoadBalancerSourceRanges) > 0 {
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerSourceRanges = networkPublishing.LoadBalancerSourceRanges
}
if networkPublishing.LoadBalancerClass != nil {
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerClass = networkPublishing.LoadBalancerClass
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can simplify

Suggested change
if len(networkPublishing.LoadBalancerSourceRanges) > 0 {
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerSourceRanges = networkPublishing.LoadBalancerSourceRanges
}
if networkPublishing.LoadBalancerClass != nil {
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerClass = networkPublishing.LoadBalancerClass
}
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerSourceRanges = networkPublishing.LoadBalancerSourceRanges
contourModel.Spec.NetworkPublishing.Envoy.LoadBalancerClass = networkPublishing.LoadBalancerClass

Comment on lines +300 to +308
// Optional LoadBalancer Service fields from ContourDeployment networkPublishing.
if epType == model.LoadBalancerServicePublishingType {
if len(contour.Spec.NetworkPublishing.Envoy.LoadBalancerSourceRanges) > 0 {
svc.Spec.LoadBalancerSourceRanges = contour.Spec.NetworkPublishing.Envoy.LoadBalancerSourceRanges
}
if contour.Spec.NetworkPublishing.Envoy.LoadBalancerClass != nil {
svc.Spec.LoadBalancerClass = contour.Spec.NetworkPublishing.Envoy.LoadBalancerClass
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets move these under load balancer type case

	switch epType {
	case model.LoadBalancerServicePublishingType:
       // all loadbalancer type related fields set here

Comment on lines +336 to +339
// LoadBalancerSourceRanges is an optional list of IP ranges in CIDR form
// which are allowed to access the LoadBalancer type Envoy Service.
// This maps to Service.spec.loadBalancerSourceRanges.
// Only applies when Type is LoadBalancerService.

@tsaarni tsaarni Aug 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could add This field may be ignored if the cloud-provider does not support it

Suggested change
// LoadBalancerSourceRanges is an optional list of IP ranges in CIDR form
// which are allowed to access the LoadBalancer type Envoy Service.
// This maps to Service.spec.loadBalancerSourceRanges.
// Only applies when Type is LoadBalancerService.
// LoadBalancerSourceRanges is an optional list of IP ranges in CIDR form
// which are allowed to access the LoadBalancer type Envoy Service.
// This maps to Service.spec.loadBalancerSourceRanges.
// This field may be ignored if the cloud-provider does not support it.
// Only applies when Type is LoadBalancerService.

Comment on lines +344 to +346
// LoadBalancerClass is the class of the load balancer implementation
// to use for the Envoy Service when Type is LoadBalancerService.
// This maps to Service.spec.loadBalancerClass.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// LoadBalancerClass is the class of the load balancer implementation
// to use for the Envoy Service when Type is LoadBalancerService.
// This maps to Service.spec.loadBalancerClass.
// LoadBalancerClass is the class of the load balancer implementation
// to use for the Envoy Service when Type is LoadBalancerService.
// This maps to Service.spec.loadBalancerClass.
// Once set, it cannot be changed without recreating the Service.
// Only applies when Type is LoadBalancerService.

@tsaarni tsaarni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@VedantMadane Thanks for contributing! I left some inline comments to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/small A small change that needs one line of explanation in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configuring Envoy Service loadBalancerSourceRanges/loadBalancerClass via ContourDeployment

3 participants