Skip to content

Commit c106673

Browse files
committed
Infra: Add Dedicated Host resource
Add a Dedicated Host resource definition and add support to define Dedicate Hosts for Infrastructure cluster resources, to allow creation of Dedicated Hosts during resource creation.
1 parent 1656309 commit c106673

7 files changed

+193
-0
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/conditions_consts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ const (
8888
// NetworkReconciliationFailedReason used when an error occurs during network reconciliation.
8989
NetworkReconciliationFailedReason = "NetworkReconciliationFailed"
9090

91+
// VPCDedicatedHostReadyCondition reports on the successful reconcilication of a VPC Dedicated Host.
92+
VPCDedicatedHostReadyCondition capiv1beta1.ConditionType = "VPCDedicatedHostReady"
93+
// VPCDedicatedHostReconciliationFailedReason used when an error occurs during VPC Dedicated Host reconciliation.
94+
VPCDedicatedHostReconciliationFailedReason = "VPCDedicatedHostReconciliationFailed"
95+
9196
// VPCSecurityGroupReadyCondition reports on the successful reconciliation of a VPC.
9297
VPCSecurityGroupReadyCondition capiv1beta1.ConditionType = "VPCSecurityGroupReady"
9398
// VPCSecurityGroupReconciliationFailedReason used when an error occurs during VPC reconciliation.

api/v1beta2/ibmvpccluster_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ type IBMVPCClusterSpec struct {
5656
// +optional
5757
ControlPlaneLoadBalancer *VPCLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`
5858

59+
// DedicatedHosts represents the Dedicated Hosts to create for the cluster.
60+
DedicatedHosts []VPCDedicatedHost `json:"dedicatedHosts,omitempty"`
61+
5962
// image represents the Image details used for the cluster.
6063
// +optional
6164
Image *ImageSpec `json:"image,omitempty"`
@@ -288,6 +291,11 @@ type IBMVPCClusterStatus struct {
288291
// dep: rely on Network instead.
289292
VPC VPC `json:"vpc,omitempty"`
290293

294+
// DedicatedHosts references the Dedicated Hosts of the cluster.
295+
// The map simplifies lookups.
296+
// +optional
297+
DedicatedHosts map[string]*ResourceStatus `json:"dedicatedHosts,omitempty"`
298+
291299
// image is the status of the VPC Custom Image.
292300
// +optional
293301
Image *ResourceStatus `json:"image,omitempty"`

api/v1beta2/types.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ var (
279279
ResourceTypePublicGateway = ResourceType("publicGateway")
280280
// ResourceTypeCustomImage is a VPC Custom Image.
281281
ResourceTypeCustomImage = ResourceType("customImage")
282+
// ResourceTypeDedicatedHost is a VPC Dedicated Host.
283+
ResourceTypeDedicatedHost = ResourceType("dedicatedHost")
282284
)
283285

284286
const (
@@ -388,6 +390,31 @@ type NetworkInterface struct {
388390
Subnet string `json:"subnet,omitempty"`
389391
}
390392

393+
// VPCDedicatedHost represents a VPC Dedicated Host.
394+
// +kubebuilder:validation:XValidation:rule="has(self.id) || has(self.name)",message="an id or a name must be defined"
395+
// +kubebuilder:validation:XValidation:rule="(has(self.profile) && has(self.name)) || !has(self.profile)",message="a name must be defined if a profile has been defined"
396+
type VPCDedicatedHost struct {
397+
// Group defines the VPC Dedicated Host Group the host resides in.
398+
// +optional
399+
Group *string `json:"group,omitempty"`
400+
401+
// ID defines the ID of a VPC Dedicated Host.
402+
// +optional
403+
ID *string `json:"id,omitempty"`
404+
405+
// Name defines the name of a VPC Dedicated Host.
406+
// +optional
407+
Name *string `json:"name,omitempty"`
408+
409+
// Profile defines the profile of a VPC Dedicated Host.
410+
// +optional
411+
Profile *string `json:"profile,omitempty"`
412+
413+
// Zone defines the zone of a VPC Dedicated Host.
414+
// +required
415+
Zone string `json:"zone"`
416+
}
417+
391418
// VPCLoadBalancerBackendPoolMember represents a VPC Load Balancer Backend Pool Member.
392419
type VPCLoadBalancerBackendPoolMember struct {
393420
// LoadBalancer defines the Load Balancer the Pool Member is for.
@@ -411,6 +438,7 @@ type VPCLoadBalancerBackendPoolMember struct {
411438
// +kubebuilder:validation:XValidation:rule="(has(self.dedicatedHost) && !has(self.dedicatedHostGroup) && !has(self.placementGroup)) || (!has(self.dedicatedHost) && has(self.dedicatedHostGroup) && !has(self.placementGroup)) || (!has(self.dedicatedHost) && !has(self.dedicatedHostGroup) && has(self.placementGroup))",message="only one of dedicatedHost, dedicatedHostGroup, or placementGroup must be defined for machine placement"
412439
type VPCMachinePlacementTarget struct {
413440
// DedicatedHost defines the Dedicated Host to place a VPC Machine (Instance) on.
441+
// TODO(cjschaef): Migrate to unified type with DedicatedHostProfile.
414442
// +optional
415443
DedicatedHost *VPCResource `json:"dedicatedHost,omitempty"`
416444

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 58 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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,38 @@ spec:
436436
rule: has(self.id) || has(self.name)
437437
type: array
438438
type: object
439+
dedicatedHosts:
440+
description: DedicatedHosts represents the Dedicated Hosts to create
441+
for the cluster.
442+
items:
443+
description: VPCDedicatedHost represents a VPC Dedicated Host.
444+
properties:
445+
group:
446+
description: Group defines the VPC Dedicated Host Group the
447+
host resides in.
448+
type: string
449+
id:
450+
description: ID defines the ID of a VPC Dedicated Host.
451+
type: string
452+
name:
453+
description: Name defines the name of a VPC Dedicated Host.
454+
type: string
455+
profile:
456+
description: Profile defines the profile of a VPC Dedicated
457+
Host.
458+
type: string
459+
zone:
460+
description: Zone defines the zone of a VPC Dedicated Host.
461+
type: string
462+
required:
463+
- zone
464+
type: object
465+
x-kubernetes-validations:
466+
- message: an id or a name must be defined
467+
rule: has(self.id) || has(self.name)
468+
- message: a name must be defined if a profile has been defined
469+
rule: (has(self.profile) && has(self.name)) || !has(self.profile)
470+
type: array
439471
image:
440472
description: image represents the Image details used for the cluster.
441473
properties:
@@ -1162,6 +1194,30 @@ spec:
11621194
description: ControlPlaneLoadBalancerState is the status of the load
11631195
balancer.
11641196
type: string
1197+
dedicatedHosts:
1198+
additionalProperties:
1199+
description: ResourceStatus identifies a resource by id (and name)
1200+
and whether it is ready.
1201+
properties:
1202+
id:
1203+
description: id defines the Id of the IBM Cloud resource status.
1204+
type: string
1205+
name:
1206+
description: name defines the name of the IBM Cloud resource
1207+
status.
1208+
type: string
1209+
ready:
1210+
description: ready defines whether the IBM Cloud resource is
1211+
ready.
1212+
type: boolean
1213+
required:
1214+
- id
1215+
- ready
1216+
type: object
1217+
description: |-
1218+
DedicatedHosts references the Dedicated Hosts of the cluster.
1219+
The map simplifies lookups.
1220+
type: object
11651221
image:
11661222
description: image is the status of the VPC Custom Image.
11671223
properties:

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,42 @@ spec:
287287
rule: has(self.id) || has(self.name)
288288
type: array
289289
type: object
290+
dedicatedHosts:
291+
description: DedicatedHosts represents the Dedicated Hosts
292+
to create for the cluster.
293+
items:
294+
description: VPCDedicatedHost represents a VPC Dedicated
295+
Host.
296+
properties:
297+
group:
298+
description: Group defines the VPC Dedicated Host Group
299+
the host resides in.
300+
type: string
301+
id:
302+
description: ID defines the ID of a VPC Dedicated Host.
303+
type: string
304+
name:
305+
description: Name defines the name of a VPC Dedicated
306+
Host.
307+
type: string
308+
profile:
309+
description: Profile defines the profile of a VPC Dedicated
310+
Host.
311+
type: string
312+
zone:
313+
description: Zone defines the zone of a VPC Dedicated
314+
Host.
315+
type: string
316+
required:
317+
- zone
318+
type: object
319+
x-kubernetes-validations:
320+
- message: an id or a name must be defined
321+
rule: has(self.id) || has(self.name)
322+
- message: a name must be defined if a profile has been
323+
defined
324+
rule: (has(self.profile) && has(self.name)) || !has(self.profile)
325+
type: array
290326
image:
291327
description: image represents the Image details used for the
292328
cluster.

0 commit comments

Comments
 (0)