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 basic types for VPC #1670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjschaef
Copy link
Contributor

@cjschaef cjschaef commented Mar 18, 2024

Create a basic VPC resource type that VPC definitions will use.

What this PR does / why we need it: VPC updates will need references to generic VPC resources. This could be shared with PowerVS, if they wish to adopt them.

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 # N/A

Special notes for your reviewer: Replaces #1668

/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:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 18, 2024
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 18, 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 18, 2024
Copy link

netlify bot commented Mar 18, 2024

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

Name Link
🔨 Latest commit dc4e223
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/660dc42d54c9c000082eab2f
😎 Deploy Preview https://deploy-preview-1670--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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 19, 2024
@cjschaef cjschaef marked this pull request as ready for review March 21, 2024 14:47
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 21, 2024
@mkumatag
Copy link
Member

/cc @Karthik-K-N @Prajyot-Parab

@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 Mar 22, 2024
@Prajyot-Parab
Copy link
Contributor

lgtm
@Karthik-K-N ptal

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cjschaef
Once this PR has been reviewed and has the lgtm label, please assign mkumatag for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Comment on lines 154 to 276
Name string `json:"name"`

// id is the ID of the COS instance.
// +optional
ID *string `json:"id,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need both Name and ID field?

Copy link
Contributor

Choose a reason for hiding this comment

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

We usually have both Name and ID fields for resources, just incase want to speed up the look up when ID is known.

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 can remove, I simply copied the COSInstance from PowerVS code, as is.
If you have found you don't need name, I will remove it here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the current PowerVS has no ID's, I kind of favor Id's over names and currently expect CAPI will not be creating COS Instances or resources....so I will see about using Id's over names ATM.
Will update.

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 dropped Name for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot drop Name as thats the only way user can specify the Name of COSInstance.

Also It wont be good to add VPCResource to COSInstance as both are two different entities in IBM Cloud. May be if we would rename VPCResource to something else to more appropriate as its just represents ID and Name in general, then only we can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My expectation at this time, is that the controller will not be creating COS resources, but it may be expected to create a VPC Custom Image, using a qcow2 file in a COS bucket, hence the need for this COS struct. I could rely only on a COS bucket CRN, but if this resource can be re-used, I expected Name/ID would be more beneficial, fields set depending on the requirements (PowerVS vs. VPC, etc.)

However, this is my best assumption on the workflow, as limitations may require changes and I am unsure if PowerVS creates COS resources (bucket maybe?) for the VSI Image. So now I wonder if VPC should deviate from the flow PowerVS uses.
It is early on in development, so I can mirror the flow PowerVS uses, for consistency, which would mean I follow similar field requirements (Name's)?

Perhaps you have an opinion on whether VPC should follow similar processes/expectations as PowerVS, when it makes sense. I am not opposed to relying on the controller to create COS resources if necessary, but I had expected the controller to rely on an existing COS Instance and Bucket and ideally the qcow2 Object holding the RHCOS image, and not be responsible for creating it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is what causing confusion, There are two things

  1. In PowerVS we create cos instance and bucket to upload the ignition data as a object and pass the object URL as userdata while creating machine.

  2. We have ibmpowervs_image_controller which takes care of importing the RHCOS image from respective COS bucket to where redhat will push the image into the PowerVS service instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question I guess I still have is, do the COS instance and bucket need to be created as a prerequisite? I hadn't seen anything in the CAPI code that creates the instance and the bucket (only the Object/File), but I certainly could have missed that.

If this is the case, and I would follow the same flow as PowerVS (create the COS instance and bucket outside CAPI), that will influence what values I want, although I have seen I am limited by the IBM COS SDK, as far as values as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do create COS instance and bucket as a part of IBMPowerVSCluster reconciler

if err := clusterScope.ReconcileCOSInstance(); err != nil {
conditions.MarkFalse(powerVSCluster, infrav1beta2.COSInstanceReadyCondition, infrav1beta2.COSInstanceReconciliationFailedReason, capiv1beta1.ConditionSeverityError, err.Error())
return reconcile.Result{}, err
}

Comment on lines 162 to 153
BucketName *string `json:"bucketName,omitempty"`

// bucketID is the IBM Cloud COS bucket ID.
// +optional
BucketID *string `json:"bucketID,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as cos (do we really need both Name and ID field?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, I can remove if you have found both to be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same update as above, will try only relying on ID's

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 dropped BucketName for now.

Comment on lines 154 to 276
Name string `json:"name"`

// id is the ID of the COS instance.
// +optional
ID *string `json:"id,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually have both Name and ID fields for resources, just incase want to speed up the look up when ID is known.

Name *string `json:"name,omitempty"`

// type is the type of VPC resource.
Type *ResourceType `json:"type,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Would like to understand how this will be used. any example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A VPCResource can be any kind of VPC resource (VSI, LB, SG, SGR, etc.).
Since I would only have a name or ID, it is helpful to have additional details as to what type of resource it is, IMHO.

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 dropped Type for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

same comments as above, if you have a plan on how to use that ID in controller that might help us in understanding this better.

@k8s-ci-robot k8s-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 27, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 27, 2024
// bucketID is the IBM Cloud COS bucket ID.
// +optional
BucketID *string `json:"bucketID,omitempty"`

Copy link
Contributor

Choose a reason for hiding this comment

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

So if we want to reuse the same struct for PowerVS as well then lets add BucketName and Name here.
So this allows us to create and use the COSinstance and Bucket with user provided name.

Just for clarification, In PowerVS we create these resources to upload the ignition data.

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 plan to handle the process for VSI Custom Image using a VPC unique type instead, and since Ignition data management is expected to occur elsewhere, I don't think COS details like this are necessary. I will divert from the PowerVS path in respect to COS.

I will be removing this COSInstanceReference type as I don't expect to need it for VPC based on my findings.


// bucketID is the IBM Cloud COS bucket ID.
// +optional
BucketID *string `json:"bucketID,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.

I need to swap back to BucketName, I don't think the IBM COS SDK provides additional details I want to use this.
Regardless of whether I expect CAPI to create COS instances and buckets.

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.

@cjschaef I think we are mixing 2 things here - COS bucket for the image import and the ignition data. I recommend you @Karthik-K-N @Prajyot-Parab and @cjschaef please setup a meeting offline to discuss on the spec considering the amount of time we are left with for the implementation.

@Karthik-K-N
Copy link
Contributor

@cjschaef I think we are mixing 2 things here - COS bucket for the image import and the ignition data. I recommend you @Karthik-K-N @Prajyot-Parab and @cjschaef please setup a meeting offline to discuss on the spec considering the amount of time we are left with for the implementation.

Sure, We can do this if there are still confusions on the workflow.

@cjschaef
Copy link
Contributor Author

cjschaef commented Apr 1, 2024

@mkumatag @Karthik-K-N
Based on the findings I've had, reviewing the PowerVS code, expectations, and dependencies, my expectations for the VPC path, is not to rely on CAPI controllers to create COS resources (COS Instance, Bucket, or Object).

Instead, I plan to rely on the COS Instance ID, the Bucket Name, and likely the COS Object Name, with the alternative being I can rely on the Object URL instead, but that depends on IBM Cloud VPC API's, which I have to re-review.

If PowerVS does not wish or plan to share this common COS Instance type, I will not add any additional fields to accommodate PowerVS (e.g., COS Instance Name).

Based on my discoveries, I have decided to drop COS altogether for VPC related support. References to any necessary COS resources will be handled as needed, using ObjectURL's, and not referencing Instances, Buckets, etc.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2024
@Prajyot-Parab
Copy link
Contributor

@Karthik-K-N ptal, lets merge if all okay

@@ -396,3 +396,17 @@ type VPCEndpoint struct {
// +optional
LBID *string `json:"loadBalancerIPID,omitempty"`
}

// VPCResource represents a specific VPC resource.
// +kubebuilder:validation:XValidation:rule="!has(self.id) && !has(self.name)",message="an id or name must be provided"
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 validation is written inversely, I will correct it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Create a basic VPC resource type that VPC definitions
will use.
@mkumatag mkumatag added this to the Next milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants