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
  • Loading branch information
cjschaef authored Oct 7, 2024
1 parent 556e3ec commit 959867b
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Up @@ -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.
Expand All @@ -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"`
Expand Down Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 959867b

Please sign in to comment.