Skip to content

Commit

Permalink
VPC: Extend VPC related API's for v2 VPC reconcile (kubernetes-sigs#1883
Browse files Browse the repository at this point in the history
)

Extend the API's used in the v2 support of reconciling
VPC for the VPCCluster support.
  • Loading branch information
cjschaef authored Jul 18, 2024
1 parent 5b01057 commit 63be00c
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 3 deletions.
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
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

0 comments on commit 63be00c

Please sign in to comment.