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

✨ implement CAPI IPAM contract support #769

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

schrej
Copy link
Member

@schrej schrej commented Oct 19, 2022

What this PR does / why we need it:
Adds support for the CAPI IPAM contract.

To do so, the network related specs of Metal3DataTemplate were adapted to allow referencing other types of Pools than just the one provided by metal3-io/ip-address-manager. Depending on the referenced Pool type, the corresponding controller will create the correct IP claim resource.
For the metadata section, the reference was simply extended with new fields that allow to specify the api group and resource type.
For the network section a new field FromPoolRef was added, which can be used as an alternative to "IPAddressFromPool". The new field also supports references to the ip-address-manager Pools.

Since both allocation mechanisms are very similar, the implementation is fairly close as well.

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

@metal3-io-bot metal3-io-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 19, 2022
@metal3-io-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@metal3-io-bot metal3-io-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 19, 2022
@schrej
Copy link
Member Author

schrej commented Oct 19, 2022

/test all

@schrej schrej marked this pull request as ready for review November 22, 2022 13:59
@metal3-io-bot metal3-io-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2022
@schrej
Copy link
Member Author

schrej commented Nov 22, 2022

/assign @furkatgofurov7

@furkatgofurov7
Copy link
Member

/assign @furkatgofurov7

👍🏼 I'll take a closer look tomorrow

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Thanks for this work @schrej, mostly nits for the first iteration.
I can understand why this PR keeps the allocation logic of Metal3 IPAM as "default" and provides CAPI way as an alternative since it paves the way for smoother migration, but since our current CI is still not adapted to the new way of IPAM support, I wonder if have you already tested it and could share your thoughts on that regard?

api/v1beta1/metal3datatemplate_types.go Outdated Show resolved Hide resolved
baremetal/metal3data_manager.go Show resolved Hide resolved
baremetal/metal3data_manager.go Outdated Show resolved Hide resolved
baremetal/metal3data_manager.go Show resolved Hide resolved
baremetal/metal3data_manager.go Outdated Show resolved Hide resolved
baremetal/metal3data_manager.go Outdated Show resolved Hide resolved
@schrej
Copy link
Member Author

schrej commented Nov 28, 2022

I did some manual testing with the in-cluster provider and it works well.
I didn't test backwards compatibility yet, but existing e2e tests should be easy enough to adapt to that. I'll also try to work on some e2e tests for the CAPI contract. For the CAPV provider they're still waiting for a new clusterctl version that supports provisioning ipam providers (the in-cluster provider is compatible already).

@furkatgofurov7
Copy link
Member

furkatgofurov7 commented Nov 28, 2022

I did some manual testing with the in-cluster provider and it works well.

Great!

I didn't test backwards compatibility yet, but existing e2e tests should be easy enough to adapt to that. I'll also try to work on some e2e tests for the CAPI contract.

That would be nice to have to make sure we have a CI coverage for the new support. Let me know if I can help anyway with that.

For the CAPV provider they're still waiting for a new clusterctl version that supports provisioning ipam providers (the in-cluster provider is compatible already).

Which version of clusterctl specifically? do you mean v1.3,x?

@schrej
Copy link
Member Author

schrej commented Nov 28, 2022

Which version of clusterctl specifically? do you mean v1.3,x?

Yes! Release is planned for Thursday (1.12.), so not really a blocker.

@schrej schrej force-pushed the capi-ipam branch 2 times, most recently from 73f9e31 to 4f8a211 Compare November 28, 2022 12:58
Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

Nice! I like the unit tests!

One thing I'm wondering though is if this would require an API version change? It should be backwards compatible, but since we are adding new fields I'm not sure if we can continue with v1beta1.

@furkatgofurov7
Copy link
Member

@schrej do you still have time to take a look and fix the build job on this PR?

@schrej
Copy link
Member Author

schrej commented Mar 22, 2023

Hey @furkatgofurov7, sorry for the late response, I was on PTO the last few days. I'll update this PR as soon as I find time. I was struggling with e2e tests, it would be great if someone could assist with that! Maybe we can merge this and work on e2e tests in a separate PR.

@furkatgofurov7
Copy link
Member

Hey @furkatgofurov7, sorry for the late response, I was on PTO the last few days. I'll update this PR as soon as I find time.

Hi @schrej , thanks for working on this and no worries, just wanted to check in if this is on track and if there is anything we can help!

I was struggling with e2e tests, it would be great if someone could assist with that! Maybe we can merge this and work on e2e tests in a separate PR.

Anything specific we can help with e2e tests? I am fine to have a follow-up to deal with e2e tests as well.

@schrej
Copy link
Member Author

schrej commented Mar 23, 2023

Tests should be good now.

Anything specific we can help with e2e tests? I am fine to have a follow-up to deal with e2e tests as well.

I think I was mainly struggling with undestanding how they work in general, and then finding a reasonable test to extend with CAPI IPAM. There doesn't seem to be any basic "deploy a cluster and make sure it works" test, or I'm just not seeing it...

@lentzi90
Copy link
Member

I think I was mainly struggling with undestanding how they work in general, and then finding a reasonable test to extend with CAPI IPAM. There doesn't seem to be any basic "deploy a cluster and make sure it works" test, or I'm just not seeing it...

This is a good point. It is weird and surprising that the "least" test we do is a clusterctl move. I'll add an issue for an explicit "create cluster and run smoke test". Now that I think about it, the integration test that we have should probably be this. We anyway test clusterctl move in most of the other e2e tests so why would it need to be in the basic integration test?

@furkatgofurov7
Copy link
Member

There doesn't seem to be any basic "deploy a cluster and make sure it works" test, or I'm just not seeing it...

Right, most if not all of the e2e tests we have feature specific and we are missing the simple base testing e2e tests.

@furkatgofurov7
Copy link
Member

furkatgofurov7 commented Mar 24, 2023

We anyway test clusterctl move in most of the other e2e tests so why would it need to be in the basic integration test?

indeed, but since e2e tests are quite new and when pivoting was introduced we did not have them at all, so we decided to add it as part of integration tests? /cc @kashifest

@lentzi90
Copy link
Member

indeed, but since e2e tests are quite new and when pivoting was introduced we did not have them at all, so we decided to add it as part of integration tests? /cc @kashifest

Let's take this discussion in the issue instead #897

IPAddressFromIPPool string `json:"ipAddressFromIPPool,omitempty"`

// FromPoolRef is a reference to a IP pool to allocate an address from.
FromPoolRef *corev1.TypedLocalObjectReference `json:"fromPoolRef,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately these references need to be pointers, otherwise the API server complains when the reference is empty.

@mboukhalfa
Copy link
Member

In addition it might be good to add conditions regarding IP Address allocation on m3d, and a condition on m3m (if that's not there) indicating that it is waiting on data, so it's clearer why provisioning is stalling. Might be worth to analyse a bit more broadly and come up with more conditions on all of the resources as well.

We have recently added Metal3DataReadyCondition to m3m object in #836 not sure if still needs similar on m3d would be great if described in an issue.

@mboukhalfa
Copy link
Member

/assign

mboukhalfa
mboukhalfa previously approved these changes Apr 25, 2023
Copy link
Member

@mboukhalfa mboukhalfa left a comment

Choose a reason for hiding this comment

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

Thanks I am approving the PR just small nit on the way

/hold you can unhold once you think it is ready to go in

api/v1beta1/metal3datatemplate_types.go Outdated Show resolved Hide resolved
baremetal/metal3data_manager.go Show resolved Hide resolved
@metal3-io-bot metal3-io-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 25, 2023
@metal3-io-bot metal3-io-bot removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 25, 2023
@kashifest
Copy link
Member

@schrej whats the status of CAPI IPAM btw?

@schrej
Copy link
Member Author

schrej commented Apr 25, 2023

One provider is available, which is very similar to metal3-io/ip-address-management and provides in-cluster IPAM: telekom/cluster-api-ipam-provider-in-cluster
We (= VMware) are currently working on moving the repository to kubernetes-sigs.

I've also started to work on a Infoblox provider. I'm currently trying to figure out how to handle hostnames, since Infoblox can provide DNS as well, which allows to have automatic DNS records for all machines. I'll probably open an issue on CAPI level at some point.

Upstream the resources are still experimental and receive occasional changes. Right now we're discussing whether Gateway should be optional: kubernetes-sigs/cluster-api#8536

@schrej
Copy link
Member Author

schrej commented Apr 25, 2023

/unhold

@metal3-io-bot metal3-io-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 25, 2023
@lentzi90
Copy link
Member

/test-ubuntu-integration-main
/test-centos-e2e-integration-main

Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

Thanks for this, it looks solid to me!
/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 26, 2023
@schrej
Copy link
Member Author

schrej commented Apr 26, 2023

I think that one is still flaking
/test-centos-e2e-integration-main

@mboukhalfa
Copy link
Member

/approve

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mboukhalfa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 26, 2023
@metal3-io-bot metal3-io-bot merged commit 6f5bcd1 into metal3-io:main Apr 26, 2023
@mboukhalfa
Copy link
Member

One provider is available, which is very similar to metal3-io/ip-address-management and provides in-cluster IPAM: telekom/cluster-api-ipam-provider-in-cluster We (= VMware) are currently working on moving the repository to kubernetes-sigs.

I've also started to work on a Infoblox provider. I'm currently trying to figure out how to handle hostnames, since Infoblox can provide DNS as well, which allows to have automatic DNS records for all machines. I'll probably open an issue on CAPI level at some point.

Upstream the resources are still experimental and receive occasional changes. Right now we're discussing whether Gateway should be optional: kubernetes-sigs/cluster-api#8536

Would be nice to follow this on some issue on capm3 and set some todo plan for integration tests with capi ipam once it is upstream now we only tested with m3ipam right ?

@schrej schrej deleted the capi-ipam branch April 26, 2023 12:20
@schrej
Copy link
Member Author

schrej commented Apr 26, 2023

Would be nice to follow this on some issue on capm3 and set some todo plan for integration tests with capi ipam once it is upstream now we only tested with m3ipam right ?

I've opened an issue to track it, as promised in some comment here.

The IPAM contract is upstream, it's just in the exp package still, marking it as experimental. It basically makes it easier to change the API. If we change anything relevant, I'll either open a PR or an issue here to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Support for CAPI IPAM Contract
6 participants