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: Extend VPC related API's for v2 VPC reconcile #1883

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 30 additions & 3 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type AdditionalListenerSpec struct {
Port int64 `json:"port"`
}

// VPCNetworkSpec defines the desired state of the network resources for the cluster.
// VPCNetworkSpec defines the desired state of the network resources for the cluster for extended VPC Infrastructure support.
type VPCNetworkSpec struct {
// workerSubnets is a set of Subnet's which define the Worker subnets.
// +optional
Expand All @@ -113,7 +113,11 @@ type VPCNetworkSpec struct {
// +optional
ResourceGroup *string `json:"resourceGroup,omitempty"`

// TODO(cjschaef): Complete spec definition (SecurityGroups, VPC)
// vpc defines the IBM Cloud VPC for extended VPC Infrastructure support.
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have a field named VPC under IBMVPCClusterSpec, so may be lets add a comment whereever it looks appropriate on whats the difference or when to use which 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.

I added a little more detail to this field and some other fields/structs, as they related to the extended VPC Infra support.

VPC *VPCResource `json:"vpc,omitempty"`

// TODO(cjschaef): Complete spec definition (SecurityGroups, etc.)
}

// VPCSecurityGroupStatus defines a vpc security group resource status with its id and respective rule's ids.
Expand Down Expand Up @@ -146,11 +150,22 @@ type VPCLoadBalancerStatus struct {
type IBMVPCClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// dep: rely on Network instead.
VPC VPC `json:"vpc,omitempty"`

// network is the status of the VPC network resources for extended VPC Infrastructure support.
// +optional
Network *VPCNetworkStatus `json:"network,omitempty"`

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`
// +kubebuilder:default=false
Ready bool `json:"ready"`

// resourceGroup is the status of the cluster's Resource Group for extended VPC Infrastructure support.
// +optional
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`

Subnet Subnet `json:"subnet,omitempty"`
VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"`

Expand All @@ -163,6 +178,18 @@ type IBMVPCClusterStatus struct {
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`
}

// VPCNetworkStatus provides details on the status of VPC network resources for extended VPC Infrastructure support.
type VPCNetworkStatus struct {
// resourceGroup references the Resource Group for Network resources for the cluster.
// This can be the same or unique from the cluster's Resource Group.
// +optional
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`

// vpc references the status of the IBM Cloud VPC as part of the extended VPC Infrastructure support.
// +optional
VPC *ResourceStatus `json:"vpc,omitempty"`
}

// VPC holds the VPC information.
type VPC struct {
ID string `json:"id"`
Expand Down
39 changes: 39 additions & 0 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,42 @@ type VPCEndpoint struct {
// +optional
LBID *string `json:"loadBalancerIPID,omitempty"`
}

// ResourceStatus identifies a resource by id (and name) and whether it is ready.
type ResourceStatus struct {
// id defines the Id of the IBM Cloud resource status.
// +required
ID string `json:"id"`

// name defines the name of the IBM Cloud resource status.
// +optional
Name *string `json:"name,omitempty"`

// ready defines whether the IBM Cloud resource is ready.
// +required
Ready bool `json:"ready"`
}

// Set sets the ResourceStatus fields.
func (s *ResourceStatus) Set(resource ResourceStatus) {
s.ID = resource.ID
// Set the name if it hasn't been, or the incoming name won't remove it (nil).
if s.Name == nil && resource.Name != nil {
s.Name = resource.Name
}
s.Ready = resource.Ready
}

// VPCResource represents a VPC resource.
// +kubebuilder:validation:XValidation:rule="has(self.id) || has(self.name)",message="an id or name must be provided"
type VPCResource struct {
// id of the resource.
// +kubebuilder:validation:MinLength=1
// +optional
ID *string `json:"id,omitempty"`

// name of the resource.
// +kubebuilder:validation:MinLength=1
// +optional
Name *string `json:"name,omitempty"`
}
85 changes: 85 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ spec:
resourceGroup is the name of the Resource Group containing all of the newtork resources.
This can be different than the Resource Group containing the remaining cluster resources.
type: string
vpc:
description: vpc defines the IBM Cloud VPC for extended VPC Infrastructure
support.
properties:
id:
description: id of the resource.
minLength: 1
type: string
name:
description: name of the resource.
minLength: 1
type: string
type: object
x-kubernetes-validations:
- message: an id or name must be provided
rule: has(self.id) || has(self.name)
workerSubnets:
description: workerSubnets is a set of Subnet's which define the
Worker subnets.
Expand Down Expand Up @@ -413,9 +429,71 @@ spec:
description: ControlPlaneLoadBalancerState is the status of the load
balancer.
type: string
network:
description: network is the status of the VPC network resources for
extended VPC Infrastructure support.
properties:
resourceGroup:
description: |-
resourceGroup references the Resource Group for Network resources for the cluster.
This can be the same or unique from the cluster's Resource Group.
properties:
id:
description: id defines the Id of the IBM Cloud resource status.
type: string
name:
description: name defines the name of the IBM Cloud resource
status.
type: string
ready:
description: ready defines whether the IBM Cloud resource
is ready.
type: boolean
required:
- id
- ready
type: object
vpc:
description: vpc references the status of the IBM Cloud VPC as
part of the extended VPC Infrastructure support.
properties:
id:
description: id defines the Id of the IBM Cloud resource status.
type: string
name:
description: name defines the name of the IBM Cloud resource
status.
type: string
ready:
description: ready defines whether the IBM Cloud resource
is ready.
type: boolean
required:
- id
- ready
type: object
type: object
ready:
default: false
description: Ready is true when the provider resource is ready.
type: boolean
resourceGroup:
description: resourceGroup is the status of the cluster's Resource
Group for extended VPC Infrastructure support.
properties:
id:
description: id defines the Id of the IBM Cloud resource status.
type: string
name:
description: name defines the name of the IBM Cloud resource status.
type: string
ready:
description: ready defines whether the IBM Cloud resource is ready.
type: boolean
required:
- id
- ready
type: object
subnet:
description: Subnet describes a subnet.
properties:
Expand All @@ -438,6 +516,7 @@ spec:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
dep: rely on Network instead.
properties:
id:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ spec:
resourceGroup is the name of the Resource Group containing all of the newtork resources.
This can be different than the Resource Group containing the remaining cluster resources.
type: string
vpc:
description: vpc defines the IBM Cloud VPC for extended
VPC Infrastructure support.
properties:
id:
description: id of the resource.
minLength: 1
type: string
name:
description: name of the resource.
minLength: 1
type: string
type: object
x-kubernetes-validations:
- message: an id or name must be provided
rule: has(self.id) || has(self.name)
workerSubnets:
description: workerSubnets is a set of Subnet's which
define the Worker subnets.
Expand Down