Skip to content

Commit

Permalink
VPC: Extend VPC Machine API's (#1978)
Browse files Browse the repository at this point in the history
Extend the VPC Machine API's to include additional fields
and types for more VPC Machine configuration support.

Related: #1977
cjschaef authored Oct 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 556e3ec commit 959867b
Showing 7 changed files with 693 additions and 27 deletions.
8 changes: 8 additions & 0 deletions api/v1beta1/ibmvpc_conversion.go
Original file line number Diff line number Diff line change
@@ -231,3 +231,11 @@ func Convert_v1beta2_IBMVPCClusterSpec_To_v1beta1_IBMVPCClusterSpec(in *infrav1b
func Convert_v1beta2_IBMVPCClusterStatus_To_v1beta1_IBMVPCClusterStatus(in *infrav1beta2.IBMVPCClusterStatus, out *IBMVPCClusterStatus, s apiconversion.Scope) error {
return autoConvert_v1beta2_IBMVPCClusterStatus_To_v1beta1_IBMVPCClusterStatus(in, out, s)
}

func Convert_v1beta2_IBMVPCMachineStatus_To_v1beta1_IBMVPCMachineStatus(in *infrav1beta2.IBMVPCMachineStatus, out *IBMVPCMachineStatus, s apiconversion.Scope) error {
return autoConvert_v1beta2_IBMVPCMachineStatus_To_v1beta1_IBMVPCMachineStatus(in, out, s)
}

func Convert_v1beta2_NetworkInterface_To_v1beta1_NetworkInterface(in *infrav1beta2.NetworkInterface, out *NetworkInterface, s apiconversion.Scope) error {
return autoConvert_v1beta2_NetworkInterface_To_v1beta1_NetworkInterface(in, out, s)
}
38 changes: 18 additions & 20 deletions api/v1beta1/zz_generated.conversion.go

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

44 changes: 41 additions & 3 deletions api/v1beta2/ibmvpcmachine_types.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@ package v1beta2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
@@ -30,16 +33,29 @@ const (

// IBMVPCMachineSpec defines the desired state of IBMVPCMachine.
type IBMVPCMachineSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// INSERT ADDITIONAL SPEC FIELDS - desired state of machine.
// Important: Run "make" to regenerate code after modifying this file

// Name of the instance.
Name string `json:"name,omitempty"`

// CatalogOffering is the Catalog Offering OS image which would be installed on the instance.
// An OfferingCRN or VersionCRN is required, the PlanCRN is optional.
// +optional
CatalogOffering *IBMCloudCatalogOffering `json:"catalogOffering,omitempty"`

// PlacementTarget is the placement restrictions to use for the virtual server instance. No restrictions are used when this field is not defined.
// +optional
PlacementTarget *VPCMachinePlacementTarget `json:"placementTarget,omitempty"`

// Image is the OS image which would be install on the instance.
// ID will take higher precedence over Name if both specified.
Image *IBMVPCResourceReference `json:"image"`

// LoadBalancerPoolMembers is the set of IBM Cloud VPC Load Balancer Backend Pools the machine should be added to as a member.
// +optional
LoadBalancerPoolMembers []VPCLoadBalancerBackendPoolMember `json:"loadBalancerPoolMembers,omitempty"`

// Zone is the place where the instance should be created. Example: us-south-3
// TODO: Actually zone is transparent to user. The field user can access is location. Example: Dallas 2
Zone string `json:"zone"`
@@ -126,18 +142,40 @@ type IBMVPCMachineStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// InstanceID defines the IBM Cloud VPC Instance UUID.
// +optional
InstanceID string `json:"instanceID,omitempty"`

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

// Addresses contains the GCP instance associated addresses.
// Addresses contains the IBM Cloud instance associated addresses.
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`

// InstanceStatus is the status of the GCP instance for this machine.
// Conditions deefines current service state of the IBMVPCMachine.
// +optional
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`

// FailureReason will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a succinct value suitable
// for machine interpretation.
// +optional
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a more verbose string suitable
// for logging and human consumption.
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`

// InstanceStatus is the status of the IBM Cloud instance for this machine.
// +optional
InstanceStatus string `json:"instanceState,omitempty"`

// LoadBalancerPoolMembers is the status of IBM Cloud VPC Load Balancer Backend Pools the machine is a member.
// +optional
LoadBalancerPoolMembers []VPCLoadBalancerBackendPoolMember `json:"loadBalancerPoolMembers,omitempty"`
}

// +kubebuilder:object:root=true
55 changes: 55 additions & 0 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
@@ -356,12 +356,67 @@ type IBMCloudResourceReference struct {
Name *string `json:"name,omitempty"`
}

// IBMCloudCatalogOffering represents an IBM Cloud Catalog Offering resource.
// +kubebuilder:validation:XValidation:rule="(has(self.offeringCRN) && !has(self.versionCRN)) || (!has(self.offeringCRN) && has(self.versionCRN))",message="either offeringCRN or version CRN must be provided, not both"
type IBMCloudCatalogOffering struct {
// OfferingCRN defines the IBM Cloud Catalog Offering CRN. Using the OfferingCRN expects that the latest version of the Offering will be used.
// If a specific version should be used instead, rely on VersionCRN.
// +optional
OfferingCRN *string `json:"offeringCRN,omitempty"`

// PlanCRN defines the IBM Cloud Catalog Offering Plan CRN to use for the Offering.
// +optional
PlanCRN *string `json:"planCRN,omitempty"`

// VersionCRN defines the IBM Cloud Catalog Offering Version CRN. A specific version of the Catalog Offering will be used, as defined by this CRN.
// +optional
VersionCRN *string `json:"versionCRN,omitempty"`
}

// NetworkInterface holds the network interface information like subnet id.
type NetworkInterface struct {
// SecurityGroups defines a set of IBM Cloud VPC Security Groups to attach to the network interface.
// +optional
SecurityGroups []VPCResource `json:"securityGroups,omitempty"`

// Subnet ID of the network interface.
Subnet string `json:"subnet,omitempty"`
}

// VPCLoadBalancerBackendPoolMember represents a VPC Load Balancer Backend Pool Member.
type VPCLoadBalancerBackendPoolMember struct {
// LoadBalancer defines the Load Balancer the Pool Member is for.
// +required
LoadBalancer VPCResource `json:"loadBalancer"`

// Pool defines the Load Balancer Pool the Pool Member should be in.
// +required
Pool VPCResource `json:"pool"`

// Port defines the Port the Load Balancer Pool Member listens for traffic.
// +required
Port int64 `json:"port"`

// Weight of the service member. Only applicable if the pool algorithm is "weighted_round_robin".
// +optional
Weight *int64 `json:"weight,omitempty"`
}

// VPCMachinePlacementTarget represents a VPC Machine's placement restrictions.
// +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"
type VPCMachinePlacementTarget struct {
// DedicatedHost defines the Dedicated Host to place a VPC Machine (Instance) on.
// +optional
DedicatedHost *VPCResource `json:"dedicatedHost,omitempty"`

// DedicatedHostGroup defines the Dedicated Host Group to use when placing a VPC Machine (Instance).
// +optional
DedicatedHostGroup *VPCResource `json:"dedicatedHostGroup"`

// PlacementGroup defines the Placement Group to use when placing a VPC Machine (Instance).
PlacementGroup *VPCResource `json:"placementGroup,omitempty"`
}

// VPCSecurityGroupPortRange represents a range of ports, minimum to maximum.
// +kubebuilder:validation:XValidation:rule="self.maximumPort >= self.minimumPort",message="maximum port must be greater than or equal to minimum port"
type VPCSecurityGroupPortRange struct {
132 changes: 131 additions & 1 deletion api/v1beta2/zz_generated.deepcopy.go
281 changes: 278 additions & 3 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcmachines.yaml
Original file line number Diff line number Diff line change
@@ -256,6 +256,31 @@ spec:
format: int64
type: integer
type: object
catalogOffering:
description: |-
CatalogOffering is the Catalog Offering OS image which would be installed on the instance.
An OfferingCRN or VersionCRN is required, the PlanCRN is optional.
properties:
offeringCRN:
description: |-
OfferingCRN defines the IBM Cloud Catalog Offering CRN. Using the OfferingCRN expects that the latest version of the Offering will be used.
If a specific version should be used instead, rely on VersionCRN.
type: string
planCRN:
description: PlanCRN defines the IBM Cloud Catalog Offering Plan
CRN to use for the Offering.
type: string
versionCRN:
description: VersionCRN defines the IBM Cloud Catalog Offering
Version CRN. A specific version of the Catalog Offering will
be used, as defined by this CRN.
type: string
type: object
x-kubernetes-validations:
- message: either offeringCRN or version CRN must be provided, not
both
rule: (has(self.offeringCRN) && !has(self.versionCRN)) || (!has(self.offeringCRN)
&& has(self.versionCRN))
image:
description: |-
Image is the OS image which would be install on the instance.
@@ -270,12 +295,148 @@ spec:
minLength: 1
type: string
type: object
loadBalancerPoolMembers:
description: LoadBalancerPoolMembers is the set of IBM Cloud VPC Load
Balancer Backend Pools the machine should be added to as a member.
items:
description: VPCLoadBalancerBackendPoolMember represents a VPC Load
Balancer Backend Pool Member.
properties:
loadBalancer:
description: LoadBalancer defines the Load Balancer the Pool
Member is for.
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)
pool:
description: Pool defines the Load Balancer Pool the Pool Member
should be in.
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)
port:
description: Port defines the Port the Load Balancer Pool Member
listens for traffic.
format: int64
type: integer
weight:
description: Weight of the service member. Only applicable if
the pool algorithm is "weighted_round_robin".
format: int64
type: integer
required:
- loadBalancer
- pool
- port
type: object
type: array
name:
description: Name of the instance.
type: string
placementTarget:
description: PlacementTarget is the placement restrictions to use
for the virtual server instance. No restrictions are used when this
field is not defined.
properties:
dedicatedHost:
description: DedicatedHost defines the Dedicated Host to place
a VPC Machine (Instance) on.
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)
dedicatedHostGroup:
description: DedicatedHostGroup defines the Dedicated Host Group
to use when placing a VPC Machine (Instance).
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)
placementGroup:
description: PlacementGroup defines the Placement Group to use
when placing a VPC Machine (Instance).
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)
type: object
x-kubernetes-validations:
- message: only one of dedicatedHost, dedicatedHostGroup, or placementGroup
must be defined for machine placement
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))
primaryNetworkInterface:
description: PrimaryNetworkInterface is required to specify subnet.
properties:
securityGroups:
description: SecurityGroups defines a set of IBM Cloud VPC Security
Groups to attach to the network interface.
items:
description: VPCResource represents a VPC resource.
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)
type: array
subnet:
description: Subnet ID of the network interface.
type: string
@@ -321,7 +482,8 @@ spec:
description: IBMVPCMachineStatus defines the observed state of IBMVPCMachine.
properties:
addresses:
description: Addresses contains the GCP instance associated addresses.
description: Addresses contains the IBM Cloud instance associated
addresses.
items:
description: NodeAddress contains information for the node's address.
properties:
@@ -337,12 +499,125 @@ spec:
- type
type: object
type: array
conditions:
description: Conditions deefines current service state of the IBMVPCMachine.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
reason:
description: |-
The reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may not be empty.
type: string
severity:
description: |-
Severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
failureMessage:
description: |-
FailureMessage will be set in the event that there is a terminal problem
reconciling the Machine and will contain a more verbose string suitable
for logging and human consumption.
type: string
failureReason:
description: |-
FailureReason will be set in the event that there is a terminal problem
reconciling the Machine and will contain a succinct value suitable
for machine interpretation.
type: string
instanceID:
description: InstanceID defines the IBM Cloud VPC Instance UUID.
type: string
instanceState:
description: InstanceStatus is the status of the GCP instance for
this machine.
description: InstanceStatus is the status of the IBM Cloud instance
for this machine.
type: string
loadBalancerPoolMembers:
description: LoadBalancerPoolMembers is the status of IBM Cloud VPC
Load Balancer Backend Pools the machine is a member.
items:
description: VPCLoadBalancerBackendPoolMember represents a VPC Load
Balancer Backend Pool Member.
properties:
loadBalancer:
description: LoadBalancer defines the Load Balancer the Pool
Member is for.
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)
pool:
description: Pool defines the Load Balancer Pool the Pool Member
should be in.
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)
port:
description: Port defines the Port the Load Balancer Pool Member
listens for traffic.
format: int64
type: integer
weight:
description: Weight of the service member. Only applicable if
the pool algorithm is "weighted_round_robin".
format: int64
type: integer
required:
- loadBalancer
- pool
- port
type: object
type: array
ready:
description: Ready is true when the provider resource is ready.
type: boolean
Original file line number Diff line number Diff line change
@@ -244,6 +244,31 @@ spec:
format: int64
type: integer
type: object
catalogOffering:
description: |-
CatalogOffering is the Catalog Offering OS image which would be installed on the instance.
An OfferingCRN or VersionCRN is required, the PlanCRN is optional.
properties:
offeringCRN:
description: |-
OfferingCRN defines the IBM Cloud Catalog Offering CRN. Using the OfferingCRN expects that the latest version of the Offering will be used.
If a specific version should be used instead, rely on VersionCRN.
type: string
planCRN:
description: PlanCRN defines the IBM Cloud Catalog Offering
Plan CRN to use for the Offering.
type: string
versionCRN:
description: VersionCRN defines the IBM Cloud Catalog
Offering Version CRN. A specific version of the Catalog
Offering will be used, as defined by this CRN.
type: string
type: object
x-kubernetes-validations:
- message: either offeringCRN or version CRN must be provided,
not both
rule: (has(self.offeringCRN) && !has(self.versionCRN)) ||
(!has(self.offeringCRN) && has(self.versionCRN))
image:
description: |-
Image is the OS image which would be install on the instance.
@@ -258,13 +283,150 @@ spec:
minLength: 1
type: string
type: object
loadBalancerPoolMembers:
description: LoadBalancerPoolMembers is the set of IBM Cloud
VPC Load Balancer Backend Pools the machine should be added
to as a member.
items:
description: VPCLoadBalancerBackendPoolMember represents
a VPC Load Balancer Backend Pool Member.
properties:
loadBalancer:
description: LoadBalancer defines the Load Balancer
the Pool Member is for.
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)
pool:
description: Pool defines the Load Balancer Pool the
Pool Member should be in.
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)
port:
description: Port defines the Port the Load Balancer
Pool Member listens for traffic.
format: int64
type: integer
weight:
description: Weight of the service member. Only applicable
if the pool algorithm is "weighted_round_robin".
format: int64
type: integer
required:
- loadBalancer
- pool
- port
type: object
type: array
name:
description: Name of the instance.
type: string
placementTarget:
description: PlacementTarget is the placement restrictions
to use for the virtual server instance. No restrictions
are used when this field is not defined.
properties:
dedicatedHost:
description: DedicatedHost defines the Dedicated Host
to place a VPC Machine (Instance) on.
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)
dedicatedHostGroup:
description: DedicatedHostGroup defines the Dedicated
Host Group to use when placing a VPC Machine (Instance).
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)
placementGroup:
description: PlacementGroup defines the Placement Group
to use when placing a VPC Machine (Instance).
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)
type: object
x-kubernetes-validations:
- message: only one of dedicatedHost, dedicatedHostGroup,
or placementGroup must be defined for machine placement
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))
primaryNetworkInterface:
description: PrimaryNetworkInterface is required to specify
subnet.
properties:
securityGroups:
description: SecurityGroups defines a set of IBM Cloud
VPC Security Groups to attach to the network interface.
items:
description: VPCResource represents a VPC resource.
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)
type: array
subnet:
description: Subnet ID of the network interface.
type: string

0 comments on commit 959867b

Please sign in to comment.