Skip to content

Commit 63be00c

Browse files
authored
VPC: Extend VPC related API's for v2 VPC reconcile (#1883)
Extend the API's used in the v2 support of reconciling VPC for the VPCCluster support.
1 parent 5b01057 commit 63be00c

6 files changed

+251
-3
lines changed

api/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/ibmvpccluster_types.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type AdditionalListenerSpec struct {
9898
Port int64 `json:"port"`
9999
}
100100

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

116-
// TODO(cjschaef): Complete spec definition (SecurityGroups, VPC)
116+
// vpc defines the IBM Cloud VPC for extended VPC Infrastructure support.
117+
// +optional
118+
VPC *VPCResource `json:"vpc,omitempty"`
119+
120+
// TODO(cjschaef): Complete spec definition (SecurityGroups, etc.)
117121
}
118122

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

156+
// network is the status of the VPC network resources for extended VPC Infrastructure support.
157+
// +optional
158+
Network *VPCNetworkStatus `json:"network,omitempty"`
159+
151160
// Ready is true when the provider resource is ready.
152161
// +optional
153-
Ready bool `json:"ready"`
162+
// +kubebuilder:default=false
163+
Ready bool `json:"ready"`
164+
165+
// resourceGroup is the status of the cluster's Resource Group for extended VPC Infrastructure support.
166+
// +optional
167+
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`
168+
154169
Subnet Subnet `json:"subnet,omitempty"`
155170
VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"`
156171

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

181+
// VPCNetworkStatus provides details on the status of VPC network resources for extended VPC Infrastructure support.
182+
type VPCNetworkStatus struct {
183+
// resourceGroup references the Resource Group for Network resources for the cluster.
184+
// This can be the same or unique from the cluster's Resource Group.
185+
// +optional
186+
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`
187+
188+
// vpc references the status of the IBM Cloud VPC as part of the extended VPC Infrastructure support.
189+
// +optional
190+
VPC *ResourceStatus `json:"vpc,omitempty"`
191+
}
192+
166193
// VPC holds the VPC information.
167194
type VPC struct {
168195
ID string `json:"id"`

api/v1beta2/types.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,42 @@ type VPCEndpoint struct {
400400
// +optional
401401
LBID *string `json:"loadBalancerIPID,omitempty"`
402402
}
403+
404+
// ResourceStatus identifies a resource by id (and name) and whether it is ready.
405+
type ResourceStatus struct {
406+
// id defines the Id of the IBM Cloud resource status.
407+
// +required
408+
ID string `json:"id"`
409+
410+
// name defines the name of the IBM Cloud resource status.
411+
// +optional
412+
Name *string `json:"name,omitempty"`
413+
414+
// ready defines whether the IBM Cloud resource is ready.
415+
// +required
416+
Ready bool `json:"ready"`
417+
}
418+
419+
// Set sets the ResourceStatus fields.
420+
func (s *ResourceStatus) Set(resource ResourceStatus) {
421+
s.ID = resource.ID
422+
// Set the name if it hasn't been, or the incoming name won't remove it (nil).
423+
if s.Name == nil && resource.Name != nil {
424+
s.Name = resource.Name
425+
}
426+
s.Ready = resource.Ready
427+
}
428+
429+
// VPCResource represents a VPC resource.
430+
// +kubebuilder:validation:XValidation:rule="has(self.id) || has(self.name)",message="an id or name must be provided"
431+
type VPCResource struct {
432+
// id of the resource.
433+
// +kubebuilder:validation:MinLength=1
434+
// +optional
435+
ID *string `json:"id,omitempty"`
436+
437+
// name of the resource.
438+
// +kubebuilder:validation:MinLength=1
439+
// +optional
440+
Name *string `json:"name,omitempty"`
441+
}

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclusters.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,22 @@ spec:
320320
resourceGroup is the name of the Resource Group containing all of the newtork resources.
321321
This can be different than the Resource Group containing the remaining cluster resources.
322322
type: string
323+
vpc:
324+
description: vpc defines the IBM Cloud VPC for extended VPC Infrastructure
325+
support.
326+
properties:
327+
id:
328+
description: id of the resource.
329+
minLength: 1
330+
type: string
331+
name:
332+
description: name of the resource.
333+
minLength: 1
334+
type: string
335+
type: object
336+
x-kubernetes-validations:
337+
- message: an id or name must be provided
338+
rule: has(self.id) || has(self.name)
323339
workerSubnets:
324340
description: workerSubnets is a set of Subnet's which define the
325341
Worker subnets.
@@ -413,9 +429,71 @@ spec:
413429
description: ControlPlaneLoadBalancerState is the status of the load
414430
balancer.
415431
type: string
432+
network:
433+
description: network is the status of the VPC network resources for
434+
extended VPC Infrastructure support.
435+
properties:
436+
resourceGroup:
437+
description: |-
438+
resourceGroup references the Resource Group for Network resources for the cluster.
439+
This can be the same or unique from the cluster's Resource Group.
440+
properties:
441+
id:
442+
description: id defines the Id of the IBM Cloud resource status.
443+
type: string
444+
name:
445+
description: name defines the name of the IBM Cloud resource
446+
status.
447+
type: string
448+
ready:
449+
description: ready defines whether the IBM Cloud resource
450+
is ready.
451+
type: boolean
452+
required:
453+
- id
454+
- ready
455+
type: object
456+
vpc:
457+
description: vpc references the status of the IBM Cloud VPC as
458+
part of the extended VPC Infrastructure support.
459+
properties:
460+
id:
461+
description: id defines the Id of the IBM Cloud resource status.
462+
type: string
463+
name:
464+
description: name defines the name of the IBM Cloud resource
465+
status.
466+
type: string
467+
ready:
468+
description: ready defines whether the IBM Cloud resource
469+
is ready.
470+
type: boolean
471+
required:
472+
- id
473+
- ready
474+
type: object
475+
type: object
416476
ready:
477+
default: false
417478
description: Ready is true when the provider resource is ready.
418479
type: boolean
480+
resourceGroup:
481+
description: resourceGroup is the status of the cluster's Resource
482+
Group for extended VPC Infrastructure support.
483+
properties:
484+
id:
485+
description: id defines the Id of the IBM Cloud resource status.
486+
type: string
487+
name:
488+
description: name defines the name of the IBM Cloud resource status.
489+
type: string
490+
ready:
491+
description: ready defines whether the IBM Cloud resource is ready.
492+
type: boolean
493+
required:
494+
- id
495+
- ready
496+
type: object
419497
subnet:
420498
description: Subnet describes a subnet.
421499
properties:
@@ -438,6 +516,7 @@ spec:
438516
description: |-
439517
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
440518
Important: Run "make" to regenerate code after modifying this file
519+
dep: rely on Network instead.
441520
properties:
442521
id:
443522
type: string

config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,22 @@ spec:
170170
resourceGroup is the name of the Resource Group containing all of the newtork resources.
171171
This can be different than the Resource Group containing the remaining cluster resources.
172172
type: string
173+
vpc:
174+
description: vpc defines the IBM Cloud VPC for extended
175+
VPC Infrastructure support.
176+
properties:
177+
id:
178+
description: id of the resource.
179+
minLength: 1
180+
type: string
181+
name:
182+
description: name of the resource.
183+
minLength: 1
184+
type: string
185+
type: object
186+
x-kubernetes-validations:
187+
- message: an id or name must be provided
188+
rule: has(self.id) || has(self.name)
173189
workerSubnets:
174190
description: workerSubnets is a set of Subnet's which
175191
define the Worker subnets.

0 commit comments

Comments
 (0)