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

✨ Add IPAM for nodes #142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

✨ Add IPAM for nodes #142

wants to merge 3 commits into from

Conversation

Mattes83
Copy link
Contributor

@Mattes83 Mattes83 commented Jun 6, 2024

What is the purpose of this pull request/Why do we need it?
We would like to get IPs from a fixed pool of IPs instead of relying on the DHCP.

Issue #, if available:
#130

Description of changes:

  • added IPv4PoolRef/IPv6PoolRef to both IonosCloudMachine and Network
  • workflow: IonosCloudMachine controller checks for PoolRefs and creates IPAddressClaims when needed. It then waits for an external controller to create IPAddress objects from the IPAddressClaim. Then it uses the IP from the IPAddress object to create a server via Ionos cloud api.

Special notes for your reviewer:
I did not write tests yet as I am waiting for #137 to be merged and I'd like to get some feedback about this PR first.
I am also unsure where I should put the docs, I did not find anything for the other api stuff beside the api definition itself. Maybe this is already enough?

Checklist:

  • Documentation updated
  • Unit Tests added
  • E2E Tests added
  • Includes emojis

@Mattes83 Mattes83 force-pushed the ipam branch 4 times, most recently from 30775fb to 354436f Compare June 10, 2024 09:06
@Mattes83
Copy link
Contributor Author

History should now be clean

Copy link

sonarcloud bot commented Jun 14, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@lubedacht
Copy link
Collaborator

The commit history of this PR is somehow really broken. There are too many unrelated files marked as changed.

@Mattes83
Copy link
Contributor Author

Ah...again
History is now fixed

@@ -155,6 +155,9 @@ type IonosCloudMachineSpec struct {
//+optional
AdditionalNetworks Networks `json:"additionalNetworks,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
AdditionalNetworks Networks `json:"additionalNetworks,omitempty"`
// +listType=map
// +listMapKey=networkID
AdditionalNetworks Networks `json:"additionalNetworks,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

@gfariasalves-ionos gfariasalves-ionos left a comment

Choose a reason for hiding this comment

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

For the documentation, I'd just write a new markdown file in docs/. Also have you tested your changes? If so, please proceed with e2e tests, as #137 has already been merged

// IPAMConfig contains the config for ip address management.
type IPAMConfig struct {
// IPv4PoolRef is a reference to an IPAMConfig Pool resource, which exposes IPv4 addresses.
// The nic will use an available IP address from the referenced pool.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed

Copy link
Contributor

Choose a reason for hiding this comment

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

still nic here

}

func (r *IonosCloudMachineReconciler) reconcileNormal(
ctx context.Context, cloudService *cloud.Service, machineScope *scope.Machine,
ctx context.Context, machineScope *scope.Machine, cloudService *cloud.Service,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

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 changed it so that both reconcileNormal funcs have the same order of arguments.
Shall I revert this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer the inverted order (cluster, machine) but just a nitpick

internal/service/ipam/ipam.go Outdated Show resolved Hide resolved
internal/service/ipam/ipam.go Outdated Show resolved Hide resolved
internal/service/ipam/ipam.go Outdated Show resolved Hide resolved
}
}

// default nic ipv6.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIC IPv6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed

Copy link
Contributor

Choose a reason for hiding this comment

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

still there

internal/service/ipam/ipam.go Outdated Show resolved Hide resolved
internal/service/ipam/ipam.go Show resolved Hide resolved
internal/service/ipam/ipam.go Outdated Show resolved Hide resolved
@Mattes83
Copy link
Contributor Author

Mattes83 commented Jul 2, 2024

For the documentation, I'd just write a new markdown file in docs/. Also have you tested your changes? If so, please proceed with e2e tests, as #137 has already been merged

Yes, it works and we have a running cluster built with this change.

@Mattes83
Copy link
Contributor Author

Mattes83 commented Jul 2, 2024

I will try to add docs and tests this week, but I am not sure if I will find time for it. Next week and the week after I'll be on holidays

@@ -0,0 +1,40 @@
/*
Copy link
Collaborator

@lubedacht lubedacht Jul 9, 2024

Choose a reason for hiding this comment

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

move this to types.go. I think it is small enough to also include those types

*/

// Package ipam offers services for IPAM management.
package ipam
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about an ipam package. As we already have a cloud package, which contains the general functions for IONOS Cloud, it would rather make sense to me if we then had a k8s package, containing functions to interact with Kubernetes.

Otherwise you would have a core.NewHelper and apps.NewHelper and so on

Comment on lines +40 to +49
PrimaryNICFormat = "nic-%s"

// AdditionalNICFormat is the format used for IPAddressClaims for additional nics.
AdditionalNICFormat = "nic-%s-%d"

// IPV4Format is the IP v4 format.
IPV4Format = "ipv4"

// IPV6Format is the IP v6 format.
IPV6Format = "ipv6"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a need to export these consts to other packages?

IPv4PoolRef *corev1.TypedLocalObjectReference `json:"ipv4PoolRef,omitempty"`

// IPv6PoolRef is a reference to an IPAMConfig pool resource, which exposes IPv6 addresses.
// The nic will use an available IP address from the referenced pool.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants