Skip to content

Commit 73983fd

Browse files
authored
Vpc extended apis (#1895)
* VPC: API updates for extended VPC support Extending VPC related Cluster API's in order to provide additional VPC Infrastructure reconciliation support. * VPC: Update Network RG reference and lookup per API
1 parent 23e1ff3 commit 73983fd

12 files changed

+2543
-39
lines changed

api/v1beta1/zz_generated.conversion.go

Lines changed: 5 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: 173 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ type IBMVPCClusterSpec struct {
5252
ControlPlaneEndpoint capiv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`
5353

5454
// ControlPlaneLoadBalancer is optional configuration for customizing control plane behavior.
55+
// Use this for legacy support, use Network.LoadBalancers for the extended VPC support.
5556
// +optional
5657
ControlPlaneLoadBalancer *VPCLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`
5758

59+
// image represents the Image details used for the cluster.
60+
// +optional
61+
Image *ImageSpec `json:"image,omitempty"`
62+
5863
// network represents the VPC network to use for the cluster.
5964
// +optional
6065
Network *VPCNetworkSpec `json:"network,omitempty"`
@@ -87,37 +92,168 @@ type VPCLoadBalancerSpec struct {
8792
// +optional
8893
// ++kubebuilder:validation:UniqueItems=true
8994
AdditionalListeners []AdditionalListenerSpec `json:"additionalListeners,omitempty"`
95+
96+
// backendPools defines the load balancer's backend pools.
97+
// +optional
98+
BackendPools []VPCLoadBalancerBackendPoolSpec `json:"backendPools,omitempty"`
99+
100+
// securityGroups defines the Security Groups to attach to the load balancer.
101+
// Security Groups defined here are expected to already exist when the load balancer is reconciled (these do not get created when reconciling the load balancer).
102+
// +optional
103+
SecurityGroups []VPCResource `json:"securityGroups,omitempty"`
104+
105+
// subnets defines the VPC Subnets to attach to the load balancer.
106+
// Subnets defiens here are expected to already exist when the load balancer is reconciled (these do not get created when reconciling the load balancer).
107+
// +optional
108+
Subnets []VPCResource `json:"subnets,omitempty"`
90109
}
91110

92111
// AdditionalListenerSpec defines the desired state of an
93112
// additional listener on an VPC load balancer.
94113
type AdditionalListenerSpec struct {
114+
// defaultPoolName defines the name of a VPC Load Balancer Backend Pool to use for the VPC Load Balancer Listener.
115+
// +kubebuilder:validation:MinLength:=1
116+
// +kubebuilder:validation:MaxLength:=63
117+
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
118+
// +optional
119+
DefaultPoolName *string `json:"defaultPoolName,omitempty"`
120+
95121
// Port sets the port for the additional listener.
96122
// +kubebuilder:validation:Minimum=1
97123
// +kubebuilder:validation:Maximum=65535
98124
Port int64 `json:"port"`
125+
126+
// protocol defines the protocol to use for the VPC Load Balancer Listener.
127+
// Will default to TCP protocol if not specified.
128+
// +optional
129+
Protocol *VPCLoadBalancerListenerProtocol `json:"protocol,omitempty"`
99130
}
100131

101-
// VPCNetworkSpec defines the desired state of the network resources for the cluster for extended VPC Infrastructure support.
102-
type VPCNetworkSpec struct {
103-
// workerSubnets is a set of Subnet's which define the Worker subnets.
132+
// VPCLoadBalancerBackendPoolSpec defines the desired configuration of a VPC Load Balancer Backend Pool.
133+
type VPCLoadBalancerBackendPoolSpec struct {
134+
// name defines the name of the Backend Pool.
135+
// +kubebuilder:validation:MinLength:=1
136+
// +kubebuilder:validation:MaxLength:=63
137+
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
104138
// +optional
105-
WorkerSubnets []Subnet `json:"workerSubnets,omitempty"`
139+
Name *string `json:"name,omitempty"`
140+
141+
// algorithm defines the load balancing algorithm to use.
142+
// +required
143+
Algorithm VPCLoadBalancerBackendPoolAlgorithm `json:"algorithm"`
144+
145+
// healthMonitor defines the backend pool's health monitor.
146+
// +required
147+
HealthMonitor VPCLoadBalancerHealthMonitorSpec `json:"healthMonitor"`
148+
149+
// protocol defines the protocol to use for the Backend Pool.
150+
// +required
151+
Protocol VPCLoadBalancerBackendPoolProtocol `json:"protocol"`
152+
}
153+
154+
// VPCLoadBalancerHealthMonitorSpec defines the desired state of a Health Monitor resource for a VPC Load Balancer Backend Pool.
155+
// kubebuilder:validation:XValidation:rule="self.dely > self.timeout",message="health monitor's delay must be greater than the timeout"
156+
type VPCLoadBalancerHealthMonitorSpec struct {
157+
// delay defines the seconds to wait between health checks.
158+
// +kubebuilder:validation:Minimum=2
159+
// +kubebuilder:validation:Maximum=60
160+
// +required
161+
Delay int64 `json:"delay"`
162+
163+
// retries defines the max retries for health check.
164+
// +kubebuilder:validation:Minimum=1
165+
// +kubebuilder:validation:Maximum=10
166+
// +required
167+
Retries int64 `json:"retries"`
168+
169+
// port defines the port to perform health monitoring on.
170+
// +kubebuilder:validation:Minimum=1
171+
// +kubebuilder:validation:Maximum=65535
172+
// +optional
173+
Port *int64 `json:"port,omitempty"`
174+
175+
// timeout defines the seconds to wait for a health check response.
176+
// +kubebuilder:validation:Minimum=1
177+
// +kubebuilder:validation:Maximum=59
178+
// +required
179+
Timeout int64 `json:"timeout"`
180+
181+
// type defines the protocol used for health checks.
182+
// +required
183+
Type VPCLoadBalancerBackendPoolHealthMonitorType `json:"type"`
106184

185+
// urlPath defines the URL to use for health monitoring.
186+
// +kubebuilder:validation:Pattern=`^\/(([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})+(\/([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})*)*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:@\/?]|%[a-fA-F0-9]{2})*)?$`
187+
// +optional
188+
URLPath *string `json:"urlPath,omitempty"`
189+
}
190+
191+
// ImageSpec defines the desired state of the VPC Custom Image resources for the cluster.
192+
// +kubebuilder:validation:XValidation:rule="(!has(self.cosInstance) && !has(self.cosBucket) && !has(self.cosObject)) || (has(self.cosInstance) && has(self.cosBucket) && has(self.cosObject))",message="if any of cosInstance, cosBucket, or cosObject are specified, all must be specified"
193+
// +kubebuilder:validation:XValidation:rule="has(self.name) || has(self.crn) || (has(self.cosInstance) && has(self.cosBucket) && has(self.cosObject))",message="an existing image name or crn must be provided, or to create a new image the cos resources must be provided, with or without a name"
194+
type ImageSpec struct {
195+
// name is the name of the desired VPC Custom Image.
196+
// +kubebuilder:validation:MinLength:=1
197+
// +kubebuilder:validation:MaxLength:=63
198+
// +kubebuilder:validation:Pattern='/^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$/'
199+
// +optional
200+
Name *string `json:"name,omitempty"`
201+
202+
// crn is the IBM Cloud CRN of the existing VPC Custom Image.
203+
// +optional
204+
CRN *string `json:"crn,omitempty"`
205+
206+
// cosInstance is the name of the IBM Cloud COS Instance containing the source of the image, if necessary.
207+
// +optional
208+
COSInstance *string `json:"cosInstance,omitempty"`
209+
210+
// cosBucket is the name of the IBM Cloud COS Bucket containing the source of the image, if necessary.
211+
// +optional
212+
COSBucket *string `json:"cosBucket,omitempty"`
213+
214+
// cosBucketRegion is the COS region the bucket is in.
215+
// +optional
216+
COSBucketRegion *string `json:"cosBucketRegion,omitempty"`
217+
218+
// cosObject is the name of a IBM Cloud COS Object used as the source of the image, if necessary.
219+
// +optional
220+
COSObject *string `json:"cosObject,omitempty"`
221+
222+
// operatingSystem is the Custom Image's Operating System name.
223+
// +optional
224+
OperatingSystem *string `json:"operatingSystem,omitempty"`
225+
226+
// resourceGroup is the Resource Group to create the Custom Image in.
227+
// +optional
228+
ResourceGroup *IBMCloudResourceReference `json:"resourceGroup,omitempty"`
229+
}
230+
231+
// VPCNetworkSpec defines the desired state of the network resources for the cluster for extended VPC Infrastructure support.
232+
type VPCNetworkSpec struct {
107233
// controlPlaneSubnets is a set of Subnet's which define the Control Plane subnets.
108234
// +optional
109235
ControlPlaneSubnets []Subnet `json:"controlPlaneSubnets,omitempty"`
110236

111-
// resourceGroup is the name of the Resource Group containing all of the newtork resources.
237+
// loadBalancers is a set of VPC Load Balancer definitions to use for the cluster.
238+
// +optional
239+
LoadBalancers []VPCLoadBalancerSpec `json:"loadBalancers,omitempty"`
240+
241+
// resourceGroup is the Resource Group containing all of the newtork resources.
112242
// This can be different than the Resource Group containing the remaining cluster resources.
113243
// +optional
114-
ResourceGroup *string `json:"resourceGroup,omitempty"`
244+
ResourceGroup *IBMCloudResourceReference `json:"resourceGroup,omitempty"`
245+
246+
// securityGroups is a set of VPCSecurityGroup's which define the VPC Security Groups that manage traffic within and out of the VPC.
247+
// +optional
248+
SecurityGroups []VPCSecurityGroup `json:"securityGroups,omitempty"`
249+
250+
// workerSubnets is a set of Subnet's which define the Worker subnets.
251+
// +optional
252+
WorkerSubnets []Subnet `json:"workerSubnets,omitempty"`
115253

116254
// vpc defines the IBM Cloud VPC for extended VPC Infrastructure support.
117255
// +optional
118256
VPC *VPCResource `json:"vpc,omitempty"`
119-
120-
// TODO(cjschaef): Complete spec definition (SecurityGroups, etc.)
121257
}
122258

123259
// VPCSecurityGroupStatus defines a vpc security group resource status with its id and respective rule's ids.
@@ -148,11 +284,14 @@ type VPCLoadBalancerStatus struct {
148284

149285
// IBMVPCClusterStatus defines the observed state of IBMVPCCluster.
150286
type IBMVPCClusterStatus struct {
151-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
152287
// Important: Run "make" to regenerate code after modifying this file
153288
// dep: rely on Network instead.
154289
VPC VPC `json:"vpc,omitempty"`
155290

291+
// image is the status of the VPC Custom Image.
292+
// +optional
293+
Image *ResourceStatus `json:"image,omitempty"`
294+
156295
// network is the status of the VPC network resources for extended VPC Infrastructure support.
157296
// +optional
158297
Network *VPCNetworkStatus `json:"network,omitempty"`
@@ -180,11 +319,36 @@ type IBMVPCClusterStatus struct {
180319

181320
// VPCNetworkStatus provides details on the status of VPC network resources for extended VPC Infrastructure support.
182321
type VPCNetworkStatus struct {
322+
// controlPlaneSubnets references the VPC Subnets for the cluster's Control Plane.
323+
// The map simplifies lookups.
324+
// +optional
325+
ControlPlaneSubnets map[string]*ResourceStatus `json:"controlPlaneSubnets,omitempty"`
326+
327+
// loadBalancers references the VPC Load Balancer's for the cluster.
328+
// The map simplifies lookups.
329+
// +optional
330+
LoadBalancers map[string]*VPCLoadBalancerStatus `json:"loadBalancers,omitempty"`
331+
332+
// publicGateways references the VPC Public Gateways for the cluster.
333+
// The map simplifies lookups.
334+
// +optional
335+
PublicGateways map[string]*ResourceStatus `json:"publicGateways,omitempty"`
336+
183337
// resourceGroup references the Resource Group for Network resources for the cluster.
184338
// This can be the same or unique from the cluster's Resource Group.
185339
// +optional
186340
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`
187341

342+
// securityGroups references the VPC Security Groups for the cluster.
343+
// The map simplifies lookups.
344+
// +optional
345+
SecurityGroups map[string]*ResourceStatus `json:"securityGroups,omitempty"`
346+
347+
// workerSubnets references the VPC Subnets for the cluster's Data Plane.
348+
// The map simplifies lookups.
349+
// +optional
350+
WorkerSubnets map[string]*ResourceStatus `json:"workerSubnets,omitempty"`
351+
188352
// vpc references the status of the IBM Cloud VPC as part of the extended VPC Infrastructure support.
189353
// +optional
190354
VPC *ResourceStatus `json:"vpc,omitempty"`

0 commit comments

Comments
 (0)