Skip to content
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

[feat] VLAN support for CAPL clusters #525

Merged
merged 30 commits into from
Oct 7, 2024
Merged

[feat] VLAN support for CAPL clusters #525

merged 30 commits into from
Oct 7, 2024

Conversation

tchinmai7
Copy link
Contributor

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

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 59.09091% with 27 lines in your changes missing coverage. Please review.

Project coverage is 64.70%. Comparing base (8cb7af6) to head (00c3dc3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
controller/linodemachine_controller_helpers.go 20.68% 19 Missing and 4 partials ⚠️
util/vlanips.go 86.20% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #525      +/-   ##
==========================================
- Coverage   64.73%   64.70%   -0.03%     
==========================================
  Files          78       79       +1     
  Lines        4180     4236      +56     
==========================================
+ Hits         2706     2741      +35     
- Misses       1213     1232      +19     
- Partials      261      263       +2     

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

@AshleyDumaine
Copy link
Member

For this to work we will need this PR merged, a release for the CCM cut, and the CCM version bumped here, otherwise external IPs will not get set on the Nodes.

@AshleyDumaine AshleyDumaine changed the title Initial groundwork for VLAN controller [feat] Initial groundwork for VLAN support Oct 2, 2024
@tchinmai7 tchinmai7 marked this pull request as ready for review October 2, 2024 21:33
}

func createIPsConfigMap(ctx context.Context, machineScope *scope.MachineScope, ip string) error {
return machineScope.Client.Create(ctx, &corev1.ConfigMap{
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you give an example of what is in this configmap? I wonder if we could use part of the LInodeCluster spec for this information instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a simple map of machineName -> IP address

apiVersion: v1
data:
  schinmai-test-control-plane-f4g7c: 10.0.0.3
  schinmai-test-control-plane-mfxh6: 10.0.0.2
  schinmai-test-control-plane-mhczj: 10.0.0.1
kind: ConfigMap
metadata:
  creationTimestamp: "2024-10-02T19:12:38Z"
  labels:
    clusterctl.cluster.x-k8s.io/move: "true"
  name: schinmai-test-ips
  namespace: default
  resourceVersion: "7452"
  uid: cf59bb0a-4340-4461-8317-c02748d72050

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted for a configmap so that we can have a record of what IP was assigned to which machine for updates (the linodeMachine spec doesn't have it)

Copy link
Collaborator

Choose a reason for hiding this comment

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

could we just add this info to the status on each of the LinodeMachines in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

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

still not totally sure on the consumer of this information so I might be missing part of the context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this info is indeed saved into the status of linodeMachines - When X linodeMachines are reconciled in parallel, the linodeMacine controller needs to pick an IP for each instance, independently. To avoid assigning the same IP to multiple machines, I'm using the configmap as a locking mechanism, and a record of the IPs assigned to each machine. IF the configmap was sucessfully updated by the reconcile loop, it guaranteees that no other machine can get that IP and we eliminate conflicts

@tchinmai7 tchinmai7 changed the title [feat] Initial groundwork for VLAN support [feat] VLAN support for CAPL clusters Oct 3, 2024
vlanIPsMu sync.RWMutex
// vlanIPsMap stores clusterName and a list of VlanIPs assigned to that cluster
vlanIPsMap = make(map[string]*ClusterIPs, 0)
vlanIPRange = "10.0.0.0/8"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are using /11 and /8 both. Not sure if thats intentional or we wanted to use just one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is used to inform netip.Prefix what the network prefix is, and is what makes nextIP work - the /11 is what gets assigned on the node - it could be much lower too

@tchinmai7 tchinmai7 merged commit bb94b10 into main Oct 7, 2024
10 of 12 checks passed
@tchinmai7 tchinmai7 deleted the add-vlan-spec branch October 7, 2024 17:50
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