Skip to content

Conversation

@komer3
Copy link
Contributor

@komer3 komer3 commented Jul 21, 2025

Summary

Feature-flagged support for VPC-scoped NodeBalancer backends. When enabled, control plane backends use VPC internal IPs and the NodeBalancer is created inside the target VPC. External traffic continues to egress via VPC NAT with a public IP.

Key changes

  • API: Add spec.network.enableVPCBackends (default false, immutable). When true and either spec.VPCRef or spec.VPCID is set, create the NodeBalancer in the VPC and prefer VPC backend IPs. Optional spec.network.nodeBalancerBackendIPv4Range is honored if provided.
  • Services:
    • New helpers: ShouldUseVPC(scope) and DetermineAPIServerLBPort(scope).
    • NodeBalancer creation uses VPC SubnetID and optional IPv4Range; backend registration prefers VPC internal IPs, falls back to Linode private IPs when the flag is disabled.
  • Controller: getIPPortCombo now prefers VPC IPs when enabled; factored helpers to select IPs and compose port pairs; DNS endpoint now reuses DetermineAPIServerLBPort.
  • CRDs & Docs: CRDs extended with enableVPCBackends (default false, immutable); docs updated accordingly.

Decisions

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@rahulait
Copy link
Contributor

I didn't realize we had added NB-VPC support in CAPL but with fixed /30 ranges and just needed to make it enabled by default.

Do we need changes in machinecontroller to consume the new changes in machineTemplate? Not sure how they are being used based on the current state of the PR.

@komer3
Copy link
Contributor Author

komer3 commented Jul 21, 2025

I didn't realize we had added NB-VPC support in CAPL but with fixed /30 ranges and just needed to make it enabled by default.

Do we need changes in machinecontroller to consume the new changes in machineTemplate? Not sure how they are being used based on the current state of the PR.

Yup. We added these changes few months back I think.

As for machinecontroller, we don't need to update anything. Just setting privateIP to false and removing public interface does the job!

Here is a sample linode deployed with those settings:
image

@komer3 komer3 changed the title [feat][breaking] Support VPC only backend [feat][breaking] Support VPC only backends Jul 21, 2025
@komer3 komer3 requested a review from Copilot July 21, 2025 19:16

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.22%. Comparing base (6e6db1b) to head (8fb3e11).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #803      +/-   ##
==========================================
+ Coverage   63.20%   63.22%   +0.01%     
==========================================
  Files          71       71              
  Lines        7359     7363       +4     
==========================================
+ Hits         4651     4655       +4     
  Misses       2435     2435              
  Partials      273      273              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

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 introduces VPC-only backend support for the Cluster API Provider Linode (CAPL), removing the requirement for public/private IPs on nodes. The changes enable cluster communication exclusively through VPC networks while supporting external traffic through VPC NAT with public IPs.

Key changes include:

  • Addition of EnableVPCBackends field to toggle VPC-scoped NodeBalancer creation and VPC backend IP usage
  • Refactoring of IP selection logic to prioritize VPC IPs over traditional private IPs when VPC backends are enabled
  • Simplification of NodeBalancer VPC creation conditions to check VPC references before IPv4 range requirements

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/v1alpha2/linodecluster_types.go Adds EnableVPCBackends field to NetworkSpec with immutable validation
cloud/services/loadbalancers.go Introduces helper functions and simplifies VPC NodeBalancer creation logic
internal/controller/linodecluster_controller_helpers.go Refactors IP selection logic to prioritize VPC IPs when enabled
config/crd/bases/*.yaml Updates CRDs with new EnableVPCBackends field and validation rules
cloud/services/loadbalancers_test.go Updates test cases to include new EnableVPCBackends field
internal/controller/linodecluster_controller_test.go Adds SubnetID to test data and mock call expectations
internal/controller/linodecluster_controller_helpers_test.go Updates test cases with EnableVPCBackends field
docs/src/reference/out.md Documents the new EnableVPCBackends field
hack/generate-flavors.sh Updates flavor generation log message
Comments suppressed due to low confidence (1)

internal/controller/linodecluster_controller_helpers.go:139

  • [nitpick] The variable name results could be more descriptive, such as ipPortCombos or portCombinations to better reflect its purpose.
	results = append(results, fmt.Sprintf("%s:%d", ip, apiServerLBPort))

API: add spec.network.enableVPCBackends (default false, immutable). When true and VPCRef/VPCID is set, create the NodeBalancer in the target VPC and prefer VPC backend IPs. NodeBalancerBackendIPv4Range remains optional and is honored when provided.

Services: introduce ShouldUseVPC(scope) and DetermineAPIServerLBPort(scope); EnsureNodeBalancer uses VPC SubnetID and optional IPv4Range; node registration prefers VPC internal IPs when enabled, otherwise falls back to Linode private IPs.

Controller: refactor getIPPortCombo to select VPC IPs first, factor helpers findFirstVPCInternalIP/findFirstPrivateInternalIP and buildPortCombosForIP; reuse DetermineAPIServerLBPort for DNS endpoint.

CRDs+Docs: extend LinodeCluster CRDs with enableVPCBackends (default false, immutable); update docs reference for the new field.

Tests: update unit tests to set EnableVPCBackends=true in VPC scenarios and to use new helpers; keep behavior unchanged when flag is false.
@komer3 komer3 force-pushed the vpc-only-backends branch from db1bca2 to 8fb3e11 Compare August 8, 2025 19:59
@AshleyDumaine AshleyDumaine changed the title [feat][breaking] Support VPC only backends [feat] Support VPC only backends Aug 8, 2025
@komer3 komer3 changed the title [feat] Support VPC only backends [feat] Add Support for VPC only backends Aug 8, 2025
Copy link
Collaborator

@AshleyDumaine AshleyDumaine left a comment

Choose a reason for hiding this comment

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

LGTM

@komer3 komer3 merged commit dbfb8e6 into main Aug 12, 2025
26 of 29 checks passed
@komer3 komer3 deleted the vpc-only-backends branch August 12, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants