Skip to content

Commit

Permalink
API changes to support infra creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Jan 24, 2024
1 parent d027371 commit 8f8ed21
Show file tree
Hide file tree
Showing 16 changed files with 1,311 additions and 92 deletions.
15 changes: 15 additions & 0 deletions api/v1beta1/ibmpowervs_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,18 @@ func Convert_v1beta2_IBMPowerVSMachineSpec_To_v1beta1_IBMPowerVSMachineSpec(in *

return autoConvert_v1beta2_IBMPowerVSMachineSpec_To_v1beta1_IBMPowerVSMachineSpec(in, out, s)
}

func Convert_v1beta2_IBMPowerVSClusterSpec_To_v1beta1_IBMPowerVSClusterSpec(in *infrav1beta2.IBMPowerVSClusterSpec, out *IBMPowerVSClusterSpec, s apiconversion.Scope) error {
if in.ServiceInstance.ID != nil {
out.ServiceInstanceID = *in.ServiceInstance.ID
}
return autoConvert_v1beta2_IBMPowerVSClusterSpec_To_v1beta1_IBMPowerVSClusterSpec(in, out, s)
}

func Convert_v1beta2_IBMPowerVSClusterStatus_To_v1beta1_IBMPowerVSClusterStatus(in *infrav1beta2.IBMPowerVSClusterStatus, out *IBMPowerVSClusterStatus, s apiconversion.Scope) error {
return autoConvert_v1beta2_IBMPowerVSClusterStatus_To_v1beta1_IBMPowerVSClusterStatus(in, out, s)
}

func Convert_v1beta2_IBMPowerVSImageSpec_To_v1beta1_IBMPowerVSImageSpec(in *infrav1beta2.IBMPowerVSImageSpec, out *IBMPowerVSImageSpec, s apiconversion.Scope) error {
return autoConvert_v1beta2_IBMPowerVSImageSpec_To_v1beta1_IBMPowerVSImageSpec(in, out, s)
}
4 changes: 4 additions & 0 deletions api/v1beta1/ibmvpc_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,7 @@ func Convert_Slice_Pointer_v1beta2_IBMVPCResourceReference_To_Slice_Pointer_stri
}
return nil
}

func Convert_v1beta2_VPCLoadBalancerSpec_To_v1beta1_VPCLoadBalancerSpec(in *infrav1beta2.VPCLoadBalancerSpec, out *VPCLoadBalancerSpec, s apiconversion.Scope) error {
return autoConvert_v1beta2_VPCLoadBalancerSpec_To_v1beta1_VPCLoadBalancerSpec(in, out, s)
}
198 changes: 148 additions & 50 deletions api/v1beta1/zz_generated.conversion.go

Large diffs are not rendered by default.

153 changes: 147 additions & 6 deletions api/v1beta2/ibmpowervscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,109 @@ const (

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

// ServiceInstanceID is the id of the power cloud instance where the vsi instance will get deployed.
// +kubebuilder:validation:MinLength=1
// Deprecated: use ServiceInstance instead
ServiceInstanceID string `json:"serviceInstanceID"`

// Network is the reference to the Network to use for this cluster.
// when the field is omitted, A DHCP service will be created in the Power VS server workspace and its private network will be used.
Network IBMPowerVSResourceReference `json:"network"`

// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint capiv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`

// serviceInstance is the reference to the Power VS server workspace on which the server instance(VM) will be created.
// Power VS server workspace is a container for all Power VS instances at a specific geographic region.
// serviceInstance can be created via IBM Cloud catalog or CLI.
// supported serviceInstance identifier in PowerVSResource are Name and ID and that can be obtained from IBM Cloud UI or IBM Cloud cli.
// More detail about Power VS service instance.
// https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server
// when omitted system will dynamically create the service instance
// +optional
ServiceInstance *IBMPowerVSResourceReference `json:"serviceInstance,omitempty"`

// zone is the name of Power VS zone where the cluster will be created
// possible values can be found here https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server.
// when omitted syd04 will be set as default zone.
// +kubebuilder:default=dal10
// +optional
Zone *string `json:"zone,omitempty"`

// resourceGroup name under which the resources will be created.
// when omitted default resource group of the account will be used.
// +optional
ResourceGroup *string `json:"resourceGroup,omitempty"`

// vpc contains information about IBM Cloud VPC resources.
// +optional
VPC *VPCResourceReference `json:"vpc,omitempty"`

// vpcSubnets contains information about IBM Cloud VPC Subnet resources.
// +optional
VPCSubnets []Subnet `json:"vpcSubnets,omitempty"`

// transitGateway contains information about IBM Cloud TransitGateway
// IBM Cloud TransitGateway helps in establishing network connectivity between IBM Cloud Power VS and VPC infrastructure
// more information about TransitGateway can be found here https://www.ibm.com/products/transit-gateway.
// +optional
TransitGateway *TransitGateway `json:"transitGateway,omitempty"`

// loadBalancers is optional configuration for configuring loadbalancers to control plane or data plane nodes
// when specified a vpc loadbalancer will be created and controlPlaneEndpoint will be set with associated hostname of loadbalancer.
// when omitted user is expected to set controlPlaneEndpoint.
// +optional
LoadBalancers []VPCLoadBalancerSpec `json:"loadBalancers,omitempty"`

// cosInstance contains options to configure a supporting IBM Cloud COS bucket for this
// cluster - currently used for nodes requiring Ignition
// (https://coreos.github.io/ignition/) for bootstrapping (requires
// BootstrapFormatIgnition feature flag to be enabled).
// +optional
CosInstance *CosInstance `json:"cosInstance,omitempty"`
}

// ResourceReference identifies a resource with id.
type ResourceReference struct {
// id represents the id of the resource.
ID *string `json:"id,omitempty"`
// +kubebuilder:default=false
// controllerCreated indicates whether the resource is created by the controller.
ControllerCreated *bool `json:"controllerCreated,omitempty"`
}

// IBMPowerVSClusterStatus defines the observed state of IBMPowerVSCluster.
type IBMPowerVSClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// ready is true when the provider resource is ready.
// +kubebuilder:default=false
Ready bool `json:"ready"`

// serviceInstance is the reference to the Power VS service on which the server instance(VM) will be created.
ServiceInstance *ResourceReference `json:"serviceInstance,omitempty"`

// networkID is the reference to the Power VS network to use for this cluster.
Network *ResourceReference `json:"network,omitempty"`

// dhcpServer is the reference to the Power VS DHCP server.
DHCPServer *ResourceReference `json:"dhcpServer,omitempty"`

// vpc is reference to IBM Cloud VPC resources.
VPC *ResourceReference `json:"vpc,omitempty"`

// vpcSubnet is reference to IBM Cloud VPC subnet.
VPCSubnet map[string]ResourceReference `json:"vpcSubnet,omitempty"`

// transitGateway is reference to IBM Cloud TransitGateway.
TransitGateway *ResourceReference `json:"transitGateway,omitempty"`

// cosBucket is reference to IBM Cloud COS Bucket resource.
COSBucket *ResourceReference `json:"cosBucket,omitempty"`

// loadBalancers reference to IBM Cloud VPC Loadbalancer.
LoadBalancers map[string]VPCLoadBalancerStatus `json:"loadBalancers,omitempty"`

// Conditions defines current service state of the IBMPowerVSCluster.
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -81,6 +164,64 @@ type IBMPowerVSClusterList struct {
Items []IBMPowerVSCluster `json:"items"`
}

// TransitGateway holds the TransitGateway information.
type TransitGateway struct {
Name *string `json:"name,omitempty"`
ID *string `json:"id,omitempty"`
}

// VPCResourceReference is a reference to a specific VPC resource by ID or Name
// Only one of ID or Name may be specified. Specifying more than one will result in
// a validation error.
type VPCResourceReference struct {
// ID of resource
// +kubebuilder:validation:MinLength=1
// +optional
ID *string `json:"id,omitempty"`

// Name of resource
// +kubebuilder:validation:MinLength=1
// +optional
Name *string `json:"name,omitempty"`

// IBM Cloud VPC region
Region *string `json:"region,omitempty"`
}

// CosInstance represents IBM Cloud COS instance.
type CosInstance struct {
// PresignedURLDuration defines the duration for which presigned URLs are valid.
//
// This is used to generate presigned URLs for S3 Bucket objects, which are used by
// control-plane and worker nodes to fetch bootstrap data.
//
// When enabled, the IAM instance profiles specified are not used.
// +optional
PresignedURLDuration *metav1.Duration `json:"presignedURLDuration,omitempty"`

// Name defines name of IBM cloud COS instance to be created.
// +kubebuilder:validation:MinLength:=3
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$`
Name string `json:"name,omitempty"`

// bucketName is IBM cloud COS bucket name
BucketName string `json:"bucketName,omitempty"`

// bucketRegion is IBM cloud COS bucket region
BucketRegion string `json:"bucketRegion,omitempty"`
}

// GetConditions returns the observations of the operational state of the IBMPowerVSCluster resource.
func (r *IBMPowerVSCluster) GetConditions() capiv1beta1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the IBMPowerVSCluster to the predescribed clusterv1.Conditions.
func (r *IBMPowerVSCluster) SetConditions(conditions capiv1beta1.Conditions) {
r.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&IBMPowerVSCluster{}, &IBMPowerVSClusterList{})
}
11 changes: 11 additions & 0 deletions api/v1beta2/ibmpowervsimage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ type IBMPowerVSImageSpec struct {
ClusterName string `json:"clusterName"`

// ServiceInstanceID is the id of the power cloud instance where the image will get imported.
// Deprecated: use ServiceInstance instead
ServiceInstanceID string `json:"serviceInstanceID"`

// serviceInstance is the reference to the Power VS workspace on which the server instance(VM) will be created.
// Power VS workspace is a container for all Power VS instances at a specific geographic region.
// serviceInstance can be created via IBM Cloud catalog or CLI.
// supported serviceInstance identifier in PowerVSResource are Name and ID and that can be obtained from IBM Cloud UI or IBM Cloud cli.
// More detail about Power VS service instance.
// https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server
// when omitted system will dynamically create the service instance
// +optional
ServiceInstance *IBMPowerVSResourceReference `json:"serviceInstance,omitempty"`

// Cloud Object Storage bucket name; bucket-name[/optional/folder]
Bucket *string `json:"bucket"`

Expand Down
26 changes: 25 additions & 1 deletion api/v1beta2/ibmpowervsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ type IBMPowerVSMachineSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// ServiceInstanceID is the id of the power cloud instance where the vsi instance will get deployed.
// +kubebuilder:validation:MinLength=1
// Deprecated: use ServiceInstance instead
ServiceInstanceID string `json:"serviceInstanceID"`

// serviceInstance is the reference to the Power VS workspace on which the server instance(VM) will be created.
// Power VS workspace is a container for all Power VS instances at a specific geographic region.
// serviceInstance can be created via IBM Cloud catalog or CLI.
// supported serviceInstance identifier in PowerVSResource are Name and ID and that can be obtained from IBM Cloud UI or IBM Cloud cli.
// More detail about Power VS service instance.
// https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server
// when omitted system will dynamically create the service instance
// +optional
ServiceInstance *IBMPowerVSResourceReference `json:"serviceInstance,omitempty"`

// SSHKey is the name of the SSH key pair provided to the vsi for authenticating users.
SSHKey string `json:"sshKey,omitempty"`

Expand Down Expand Up @@ -121,6 +131,20 @@ type IBMPowerVSMachineSpec struct {
// ProviderID is the unique identifier as specified by the cloud provider.
// +optional
ProviderID *string `json:"providerID,omitempty"`

// Ignition defined options related to the bootstrapping systems where Ignition is used.
// +optional
Ignition *Ignition `json:"ignition,omitempty"`
}

// Ignition defines options related to the bootstrapping systems where Ignition is used.
type Ignition struct {
// Version defines which version of Ignition will be used to generate bootstrap data.
//
// +optional
// +kubebuilder:default="2.3"
// +kubebuilder:validation:Enum="2.3";"3.0";"3.1";"3.2";"3.3";"3.4"
Version string `json:"version,omitempty"`
}

// IBMPowerVSResourceReference is a reference to a specific PowerVS resource by ID, Name or RegEx
Expand Down
34 changes: 34 additions & 0 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,40 @@ type VPCLoadBalancerSpec struct {
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
// +optional
Name string `json:"name,omitempty"`

// public indicates that load balancer is public or private
// +kubebuilder:default=true
// +optional
Public bool `json:"public,omitempty"`

// AdditionalListeners sets the additional listeners for the control plane load balancer. .
// +listType=map
// +listMapKey=port
// +optional
AdditionalListeners []AdditionalListenerSpec `json:"additionalListeners,omitempty"`
}

// AdditionalListenerSpec defines the desired state of an
// additional listener on an VPC load balancer.
type AdditionalListenerSpec struct {
// Port sets the port for the additional listener.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
Port int64 `json:"port"`
}

// VPCLoadBalancerStatus defines the status VPC load balancer.
type VPCLoadBalancerStatus struct {
// id of VPC load balancer.
// +optional
ID *string `json:"id,omitempty"`
// +optional
Name *string `json:"name,omitempty"`
// State is the status of the load balancer.
State VPCLoadBalancerState `json:"state,omitempty"`
// hostname is the hostname of load balancer.
// +optional
Hostname *string `json:"hostname,omitempty"`
}

// IBMVPCClusterStatus defines the observed state of IBMVPCCluster.
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ type NetworkInterface struct {

// Subnet describes a subnet.
type Subnet struct {
Ipv4CidrBlock *string `json:"cidr"`
Name *string `json:"name"`
ID *string `json:"id"`
Zone *string `json:"zone"`
Ipv4CidrBlock *string `json:"cidr,omitempty"`
Name *string `json:"name,omitempty"`
ID *string `json:"id,omitempty"`
Zone *string `json:"zone,omitempty"`
}

// VPCEndpoint describes a VPCEndpoint.
Expand Down
Loading

0 comments on commit 8f8ed21

Please sign in to comment.