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

VPC: Create v2 path for new Infrastructure implementation #1858

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

cjschaef
Copy link
Contributor

Create a v2 path that will be used for the new Infrastructure implementation for VPC Clusters. All new functionality will be placed in these new v2 paths, based on the new NetworkSpec field, to prevent breaking existing implementation.

What this PR does / why we need it: adds new path to fully implement VPC Cluster Infrastructure support w/o breaking current functionality

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:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

adding new VPC Infrastructure pathways

@k8s-ci-robot k8s-ci-robot added area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 26, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @cjschaef. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2024
Copy link

netlify bot commented Jun 26, 2024

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit 147250c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/669171a0c69b6f00087887a8
😎 Deploy Preview https://deploy-preview-1858--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cjschaef
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@cjschaef: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Prajyot-Parab
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 27, 2024

// CreateVPCInfrastructureAnnotation is the name of an annotation that indicates if
// VPC infrastructure should be created as part of cluster creation.
CreateVPCInfrastructureAnnotation = "vpc.cluster.x-k8s.io/create-infra"
Copy link
Contributor

Choose a reason for hiding this comment

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

@cjschaef what will be used to differentiate v2 vs v1 code path. I think in VPC we create infra by default so this annotation might not be required. Are you planning to use this as a differentiator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I plan on using that and flagging off the NetworkSpec field in the Cluster resource for the v2 path.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, If I understand correctly, in V2 path you are expecting NetworkSpec to be mandatory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. NetworkSpec is part of the new Infrastructure deployment support, and is required for that support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it thanks for the clarification,
May be we can get started with using that annotation if we can't find any alternative suitable name which matches for what we are doing but eventually we need to remove it as it may confuse the users because now also by default we create the resource.

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 could remove the annotation altogether, if we wish to start the so-called "v2" VPC support without requiring an annotation (rely only on using NetworkSpec to flag the new (v2) VPC support, creating all of the required Infrastructure.

I had expected that annotation was required in order to get CAPI to perform Infrastructure Creation/Management. But if we expect for our new (v2) support, CAPI will always be attempting to create/manage Infrastructure resources, I can drop that annotation completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another question, can CAPI be run within a cluster with only the Machine Controller running (not the Cluster/Infra Controller), so as to not attempt to reprovision Infrastructure post cluster creation/install? I had expected this annotation would help with that situation as well, to prevent additional churn by CAPI by continuing to monitor (or deleting) Infrastructure post cluster create.

Copy link
Contributor

Choose a reason for hiding this comment

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

In PowerVS v1 flow we were not creating any infra rather using existing infra and expecting user to provide them. We introduced this annotation in for v2 to make sure we need to create infra and not expecting anything from user.

This is not true for VPC, in vpc v1 flow as well we create required resources so this annotation does imply anything. But for you to differentiate V2 path as you suggested its better to go with NetworkSpec. If user set NetworkSpec you can assume its V2 flow.

Copy link
Contributor

@Karthik-K-N Karthik-K-N Jul 3, 2024

Choose a reason for hiding this comment

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

Another question, can CAPI be run within a cluster with only the Machine Controller running (not the Cluster/Infra Controller), so as to not attempt to reprovision Infrastructure post cluster creation/install? I had expected this annotation would help with that situation as well, to prevent additional churn by CAPI by continuing to monitor (or deleting) Infrastructure post cluster create.

No this annotation is nothing to do with that, But to achieve what you are expecting capi provides annotation named [cluster.x-k8s.io/managed-by](https://github.com/Karthik-K-N/cluster-api/blob/e2bf2b7d108ecd51bf7b23bf50e2432e82d8f2fe/api/v1beta1/common_types.go#L154-L160) and our controllers are configured to use them here. But the controllers will be running but will ignore the objects with this annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, thanks for the details, I will drop the annotation. and rely only on the NetworkSpec.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 5, 2024
@cjschaef
Copy link
Contributor Author

cjschaef commented Jul 8, 2024

Re-pushing to try to get CLA check to pass (no idea why it failed all of a sudden).

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 8, 2024
// This can be different than the Resource Group containing the remaining cluster resources.
ResourceGroup *string `json:"resourceGroup,omitempty"`

// TODO(cjschaef): Complete spec definition (SecurityGroups, VPC)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you planning to add any more definition as a part of this PR or in subsequent PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I plan to add additional details in more functional PR's.

}

// NewVPCClusterScope creates a new VPCClusterScope from the supplied parameters.
func NewVPCClusterScope(params VPCClusterScopeParams) (*VPCClusterScope, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still not clear on how this will be invoked and embedded into existing flow, Do you mind adding that snippet of code to this PR. Also if possible we can move api definition to seperate PR if possible.

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 gets utilized here, in this new v2 path, which allows me to modify the Cluster resource without affecting the existing VPC (legacy) support:
https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1858/files#diff-647a58f1c11f771d3ec32c60c28c4b8b29442f9915129e16eeddb59120dcc7d8R140-R146

I can attempt to break up this PR, and maybe see if adding anything more for the new VPCClusterScope use that doesn't balloon the PR too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

API only PR
#1875

Copy link
Contributor

Choose a reason for hiding this comment

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

It gets utilized here, in this new v2 path, which allows me to modify the Cluster resource without affecting the existing VPC (legacy) support:
I got that but where do you call reconcilerv2?, Something like you need to add a check to see whether vpcclusterspec.NetworkSpec is set or not, If not set go with v1 flow and if set go with new v2 flow?

If this is the case, now if you are expecting user to go with v2 flow say for IPI case but user misses to set networkspec now the controller by default with v1 flow which is not you are expecting and we cannot make networkspec mandatory also, So we dont have any way to add a validation for v2 flow. Its up-to user intelligence and documentation to go with v2 flow..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is my expectation, the burden is on the user to provide details in order to utilize the v2 flow.
The architecture deployment for the v2 flow is going to be drastically different than the existing deployment.
In order to achieve and configure this, the user will be on the hook to configure the Cluster resource properly.

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 got that but where do you call reconcilerv2?, Something like you need to add a check to see whether vpcclusterspec.NetworkSpec is set or not, If not set go with v1 flow and if set go with new v2 flow?

That is right here
https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1858/files#diff-647a58f1c11f771d3ec32c60c28c4b8b29442f9915129e16eeddb59120dcc7d8R74-R77

Otherwise, it continues with the legacy (v1) flow

Copy link
Contributor

Choose a reason for hiding this comment

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

got it thanks

Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

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

overall LGTM, may be we can merge the api pr then merge this,

Also I see lots of code duplication can be avoided like in NewClusterScope, May be once we have clear picture of v2 flow, we can combine whereever possible.

Thanks.

@cjschaef
Copy link
Contributor Author

Rebased off API updates: #1875

Yes, I imagine some refactoring could be done to handle duplicate code, but the intention is to avoid interacting/modifying the existing VPC flow to simplify testing and support (I am not familiar with the expectations with the current VPC flow). Depending on whether we expect to deprecate and remove the current flow, in favor of the extended VPC support (v2).

@@ -71,6 +71,11 @@ func (r *IBMVPCClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, err
}

// Determine whether the Cluster is designed for extended Infrastructure support, implemented in a separate path.
if ibmCluster.Spec.Network != nil {
Copy link
Member

Choose a reason for hiding this comment

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

this code block can above line 64 to avoid one extra Get call..

Copy link
Contributor Author

@cjschaef cjschaef Jul 12, 2024

Choose a reason for hiding this comment

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

I think this needs to be here, after the ibmCluster variable is defined and then populated via r.Get from the IBMVPCCluster resource on line 65-66.

Copy link
Member

Choose a reason for hiding this comment

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

yep, my bad..

}

if params.IBMVPCCluster.Spec.Network == nil || params.IBMVPCCluster.Spec.Region == "" {
return nil, fmt.Errorf("error failed to generate vpc client as NetworkSpec info is nil")
Copy link
Member

Choose a reason for hiding this comment

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

if statement is checking for Region but it is not reported in the error, this may mislead the user..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated error info

@k8s-ci-robot k8s-ci-robot removed the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 12, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 12, 2024
Create a v2 path that will be used for the new Infrastructure
implementation for VPC Clusters. All new functionality will
be placed in these new v2 paths, based on the new Network
field, to prevent breaking existing implementation.
@cjschaef
Copy link
Contributor Author

Repushing to get CLA to pass.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 12, 2024
Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 15, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjschaef, mkumatag

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5b01057 into kubernetes-sigs:main Jul 15, 2024
13 checks passed
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. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants