Skip to content

Conversation

@cjschaef
Copy link
Contributor

Extending VPC related Cluster API's in order to provide additional VPC Infrastructure reconciliation support.

What this PR does / why we need it: introduces API's that will be used for extended VPC Cluster (Infrastructure) support

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:

add additional API's for extended VPC Cluster support

@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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 23, 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 the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 23, 2024
@netlify
Copy link

netlify bot commented Jul 23, 2024

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

Name Link
🔨 Latest commit 4012d7c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/66c60b58c96a7000085b9642
😎 Deploy Preview https://deploy-preview-1895--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.

@mkumatag
Copy link
Member

/cc @Karthik-K-N

@k8s-ci-robot k8s-ci-robot requested a review from Karthik-K-N July 24, 2024 06:20
@mkumatag
Copy link
Member

/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 Jul 24, 2024

// securityGroups defines the load balancer's security groups.
// +optional
SecurityGroups []VPCResource `json:"securityGroups,omitempty"`
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 you are planing to have SG seperatly for LB as well as VPC, do you have any use case in mind?
Also we recently implemented it for PowerVS see if it helps

VPCSecurityGroups []VPCSecurityGroup `json:"vpcSecurityGroups,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.

The SG's listed for the LB merely list the SecurityGroups the LB expects to have attached during LB creation.

The SecurityGroup (VPCSecurityGroup) reconciliation occurs separately, so we expect the SG's should already exist by the time we reach LB reconciliation (or error if they do not).

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case can you please reframe the description the same for better understanding?
It looks like, you are defining the SG from scratch.

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 added some details that the SG's are expected to exist for LB reconciliation

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've also added subnet definitions to LB's, since we don't expect to default to using all subnets.


// backendPools defines the load balancer's backend pools.
// +optional
BackendPools []BackendPoolSpec `json:"backendPools,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the use case you have in mind to expose Backedpool,Do you think user should worry about it? Also what happens if user does not pass anything here?

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 currently have some default pools implemented in test code. I have not yet decided whether to leave them in, or force the user to have to define pools (no defaults).


// resourceGroup is the Resource Group to create the Custom Image in.
// +optional
ResourceGroup *IBMCloudResourceReference `json:"resourceGroup,omitempty"`
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 we have ResourceGroup at various place. Do you think this option is needed, can't we create image in cluster resource group?

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 ResourceGroup is imbedded within Power code, I do not wish reuse Power dependent code

// ResourceReference identifies a resource with id.
type ResourceReference struct {
// id represents the id of the resource.
ID *string `json:"id,omitempty"`
// +kubebuilder:default=false
// controllerCreated indicates whether the resource is created by the controller.
ControllerCreated *bool `json:"controllerCreated,omitempty"`
}

The ResourceGroup can be used for Image creation, or to retrieve an existing image. So, the RG doesn't have to match the Cluster RG.

// resourceGroup is the name of the Resource Group containing all of the newtork resources.
// loadBalancers is a set of VPC Load Balancer definitions to use for the cluster.
// +optional
LoadBalancers []VPCLoadBalancerSpec `json:"loadbalancers,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are defining here as well, We may need to add proper comment for VPCSpec.ControlplaneLoadbalancer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can try to add something to the old 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.

Added some details about legacy use versus extended support.

@cjschaef cjschaef force-pushed the vpc_extended_apis branch from 5ac1389 to 3b807d2 Compare July 24, 2024 14:17
@Karthik-K-N
Copy link
Contributor

@dharaneeshvrd please take a look when you get some time.

@mkumatag
Copy link
Member

mkumatag commented Aug 1, 2024

/cc @dharaneeshvrd

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.

I have added few comments about adding validation to all the new fields added, lets add validation for all the newly introduced fields referring the apispec from the doc here - https://cloud.ibm.com/apidocs/vpc/latest#create-load-balancer


// algorithm defines the load balancing algorithm to use.
// +required
Algorithm string `json:"algorithm"`
Copy link
Member

Choose a reason for hiding this comment

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

lets add a validation here for the Allowable values: [least_connections,round_robin,weighted_round_robin] and also a default value set when no option mentioned

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 an enum


// protocol defines the protocol to use for the Backend Pool.
// +required
Protocol string `json:"protocol"`
Copy link
Member

Choose a reason for hiding this comment

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

can we add validation here for the algorithm like Allowable values: [http,https,tcp,udp]

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 an enum

// name defines the name of the Backend Pool.
// +optional
WorkerSubnets []Subnet `json:"workerSubnets,omitempty"`
Name *string `json:"name,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

lets add a regex for the validation here - Possible values: 1 ≤ length ≤ 63, Value must match regular expression ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$

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

@dharaneeshvrd dharaneeshvrd left a comment

Choose a reason for hiding this comment

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

LGTM overall!


// securityGroups defines the load balancer's security groups.
// +optional
SecurityGroups []VPCResource `json:"securityGroups,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

In that case can you please reframe the description the same for better understanding?
It looks like, you are defining the SG from scratch.

@cjschaef cjschaef force-pushed the vpc_extended_apis branch 2 times, most recently from 8b2f334 to ee67c25 Compare August 6, 2024 00:13
@cjschaef
Copy link
Contributor Author

cjschaef commented Aug 6, 2024

Based on further investigation on requirements for Catalog Offerings, I have extended the ImageSpec to include a CatalogOffering resource now as well, to allow user to define whether an existing VPC Image is used, a Catalog Offering, or a new VPC Image gets created during Infrastructure reconciliation.

@mkumatag mkumatag added this to the v0.9.0 milestone Aug 6, 2024
@cjschaef cjschaef force-pushed the vpc_extended_apis branch from ee67c25 to 4f33c89 Compare August 6, 2024 18:42
type VPCNetworkSpec struct {
// workerSubnets is a set of Subnet's which define the Worker subnets.
// BackendPoolSpec defines the desired configuration of a VPC Load Balancer Backend Pool.
type BackendPoolSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we prefix with VPCLoadBalancer to align with other structs?

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


// HealthMonitorSpec defines the desired state of a Health Monitor resource for a VPC Load Balancer Backend Pool.
// kubebuilder:validation:XValidation:rule="self.dely > self.timeout",message="health monitor's delay must be greater than the timeout"
type HealthMonitorSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as other comment, it would be good to prefix this with VPCLoadBalancer to be more clear IMO.
Also can we keep it as VPCLoadBalancerHealthCheckSpec to align with VPC term and here also I can see you have referred as health check in many places?

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 the struct name. I was trying to stay aligned with the IBM Cloud API documentation, as it refers to the fields for health checks.

)

// CatalogOffering represents an IBM Cloud Catalog Offering resource.
type CatalogOffering struct {
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
type CatalogOffering struct {
type IBMCloudCatalogOffering struct {

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.


// catalogOffering defines an existing Catalog Offering Image.
// +optional
CatalogOffering *CatalogOffering `json:"catalogOffering,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

CatalogOffering's spec looks like to identify generic ibm cloud catalog offering, how are you planning to use that to identify the catalog image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a Catalog Offering for a VSI "image" requires either a Catalog Offering CRN or Catalog Offering Version CRN (with an optional Catalog Offering Plan CRN for either) per the IBM Cloud VPC API's.

Supplying the catalogOffering field for the ImageSpec, with one of the offeringCRN or versionCRN, with result in the VSI API calls to be made using an InstancePrototypeInstanceByCatalogOffering instead of the ...ByImage for the API calls to create a VSI.

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 the Catalog Offering since we may not have permission to validate the Image as an Offering. We will have to rely on results/errors during Machine creation.

@cjschaef cjschaef force-pushed the vpc_extended_apis branch 4 times, most recently from 7b0425c to 0e232d8 Compare August 9, 2024 14:39
@cjschaef
Copy link
Contributor Author

cjschaef commented Aug 9, 2024

Rebased to resolve mock generation.

@cjschaef cjschaef force-pushed the vpc_extended_apis branch from 0e232d8 to 4548245 Compare August 9, 2024 17:17
@cjschaef
Copy link
Contributor Author

cjschaef commented Aug 9, 2024

I dropped the Catalog Offering configuration for the Image definition, as I expect to handle it only within Machine API's and we may not have permission to validate a Catalog Offering, thus providing it in the Infrastructure is not useful.

@dharaneeshvrd
Copy link
Contributor

It seems you need to regenerate the CRD def yamls, otherwise it LGTM!

@cjschaef
Copy link
Contributor Author

@dharaneeshvrd Is there something specific I need to run to do that?

@dharaneeshvrd
Copy link
Contributor

make generate would do that.

@cjschaef
Copy link
Contributor Author

@dharaneeshvrd I have run that prior, I don't think it passes CI tests unless the CRD files are updated.
Is there something specific missing, or perhaps something I need to add into a list to generate what appears to be missing?

@dharaneeshvrd
Copy link
Contributor

@cjschaef Apologies for the confusion, it is updated properly.
LGTM, @mkumatag please review!

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.

I don't see validations working fine, please fix them.

e.g: I created following spec and it got created without any issues

apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCCluster
metadata:
  labels:
    cluster.x-k8s.io/cluster-name: test-1
  name: test-1
spec:
  region: us-south
  resourceGroup: Default
  vpc: vpc-1
  zone: us-south-1
  controlPlaneLoadBalancer:
    name: lb-test
    backendPools:
    - name: pool-1
      algorithm: invalid-algo
      healthMonitor:
        delay: 2
        retries: 1
        timeout: 1
        type: invalidtype
oc get IBMVPCCluster -A -o=yaml
apiVersion: v1
items:
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
  kind: IBMVPCCluster
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"infrastructure.cluster.x-k8s.io/v1beta2","kind":"IBMVPCCluster","metadata":{"annotations":{},"labels":{"cluster.x-k8s.io/cluster-name":"test-1"},"name":"test-1","namespace":"default"},"spec":{"controlPlaneLoadBalancer":{"backendPools":[{"algorithm":"invalid-algo","healthMonitor":{"delay":2,"retries":1,"timeout":1,"type":"invalidtype"},"name":"pool-1"}],"name":"lb-test"},"region":"us-south","resourceGroup":"Default","vpc":"vpc-1","zone":"us-south-1"}}
    creationTimestamp: "2024-08-16T07:37:55Z"
    generation: 1
    labels:
      cluster.x-k8s.io/cluster-name: test-1
    name: test-1
    namespace: default
    resourceVersion: "2534"
    uid: 5147b1a5-2251-484c-b3c4-335b0d6c57f3
  spec:
    controlPlaneEndpoint:
      host: ""
      port: 0
    controlPlaneLoadBalancer:
      backendPools:
      - algorithm: invalid-algo
        healthMonitor:
          delay: 2
          retries: 1
          timeout: 1
          type: invalidtype
        name: pool-1
        protocol: ""
      name: lb-test
      public: true
    region: us-south
    resourceGroup: Default
    vpc: vpc-1
    zone: us-south-1
kind: List
metadata:
  resourceVersion: ""

Extending VPC related Cluster API's in order to provide
additional VPC Infrastructure reconciliation support.
@cjschaef
Copy link
Contributor Author

@mkumatag I added some enum validation to some of the type fields, but I cannot validate locally to confirm things work as expected (issues with CRD resource creation). Please let me know if you see further issues.

@mkumatag
Copy link
Member

@mkumatag I added some enum validation to some of the type fields, but I cannot validate locally to confirm things work as expected (issues with CRD resource creation). Please let me know if you see further issues.

Getting a proper message now,

k apply -f test/vpc_cluster.yaml 
The IBMVPCCluster "test-1" is invalid: 
* spec.controlPlaneLoadBalancer.backendPools[0].algorithm: Unsupported value: "invalid-algo": supported values: "least_connections", "round_robin", "weighted_round_robin"
* spec.controlPlaneLoadBalancer.backendPools[0].healthMonitor.type: Unsupported value: "invalidtype": supported values: "http", "https", "tcp"
* spec.controlPlaneLoadBalancer.backendPools[0].protocol: Unsupported value: "": supported values: "http", "https", "tcp", "udp"
(base) 

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 Aug 30, 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 Aug 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit 73983fd into kubernetes-sigs:main Aug 30, 2024
@cjschaef cjschaef deleted the vpc_extended_apis branch August 30, 2024 13:26
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants