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 Nov 29, 2023
1 parent 7f4aef3 commit 6c7a301
Show file tree
Hide file tree
Showing 10 changed files with 556 additions and 49 deletions.
11 changes: 11 additions & 0 deletions api/v1beta1/ibmpowervs_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,14 @@ 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)
}
92 changes: 68 additions & 24 deletions api/v1beta1/zz_generated.conversion.go

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

90 changes: 85 additions & 5 deletions api/v1beta2/ibmpowervscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,82 @@ 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 service instance 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 service on which the server instance(VM) will be created.
// Power VS service 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 value for serviceInstance is omitted its required to set the value for zone.
// +optional
Zone *string `json:"zone,omitempty"`

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

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

// transitGateway contains information about IBM Cloud TransitGateway.
// +optional
TransitGateway *TransitGateway `json:"transitGateway,omitempty"`

// controlPlaneLoadBalancer is optional configuration for customizing control plane behavior.
// Its name reference to IBM Cloud VPC LoadBalancer service.
// +optional
ControlPlaneLoadBalancer *VPCLoadBalancerSpec `json:"controlPlaneLoadBalancer,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.
Ready bool `json:"ready"`

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

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

// dhcpServerID is the reference to the Power VS DHCP server.
DHCPServerID *string `json:"dhcpServerID,omitempty"`

// vpcID is reference to IBM Cloud VPC resources.
VPCID *string `json:"vpcID,omitempty"`

// vpcSubnetID is reference to IBM Cloud VPC subnet.
VPCSubnetID *string `json:"vpcSubnetID,omitempty"`

// transitGatewayID is reference to IBM Cloud TransitGateway.
TransitGatewayID *string `json:"transitGatewayID,omitempty"`

// ControlPlaneLoadBalancer reference to IBM Cloud VPC Loadbalancer.
ControlPlaneLoadBalancer *VPCLoadBalancerStatus `json:"controlPlaneLoadBalancer,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 +137,30 @@ 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 zone
Zone *string `json:"zone,omitempty"`
}

func init() {
SchemeBuilder.Register(&IBMPowerVSCluster{}, &IBMPowerVSClusterList{})
}
9 changes: 9 additions & 0 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ type VPCLoadBalancerSpec struct {
Name string `json:"name,omitempty"`
}

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

// IBMVPCClusterStatus defines the observed state of IBMVPCCluster.
type IBMVPCClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
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 6c7a301

Please sign in to comment.